chore: automate AI model catalog sync#32057
Open
adriandlam wants to merge 1 commit into
Open
Conversation
143b631 to
07ff037
Compare
Contributor
Review🚨 1 critical, Fix in your agentFix the following review findings in PR #32057 (https://github.com/cloudflare/cloudflare-docs/pull/32057).
Before making changes, review each finding and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g. the fix requires disproportionate effort for minimal benefit,
or the finding is factually incorrect), explain why
- If you need clarification before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
After triaging, fix all legitimate findings. For any you decide to skip,
post a comment on this PR with the finding ID and your reasoning.
---
## Code Review
### Critical (1)
#### CR-fb410b562741 · PR creation silently skipped on first run
- **File:** `.github/workflows/sync-ai-model-catalog.yml` line 124
- **Issue:** When there is no existing open PR, `gh pr list ... --jq '.[0].number'` returns `null`, making `existing` non-empty. The step then prints "Updated existing PR #null" and exits 0 without creating a PR, so catalog changes are pushed to an orphan branch.
- **Fix:** Change the jq filter to `--jq '.[0].number // empty'` and keep the `[[ -n "$existing" ]]` guard.
### Warnings (1)
#### CR-35e0ff3561ef · Incorrect empty-result handling from gh/jq
- **File:** `.github/workflows/sync-ai-model-catalog.yml` line 93
- **Issue:** When no open PR exists, `gh pr list ... --jq '.[0].number'` outputs the literal string `null`, so `existing` is non-empty and `gh pr close "$existing"` runs `gh pr close null`.
- **Fix:** Use `--jq '.[0].number // empty'` so the variable is truly empty when no PR exists.
### Suggestions (1)
#### CR-dff00a670dfc · Opaque validation failure
- **File:** `bin/fetch-catalog-models.ts` line 402
- **Issue:** When `data.result` fails `isCatalogModel`, `fetchModelDetail` returns the generic summary "invalid detail response" with no indication of which field was invalid or why the model was rejected.
- **Fix:** Make `isCatalogModel` return or accept a diagnostic callback that reports the path/reason of the first validation failure, and include that detail in the returned summary so the sync log explains why a model was rejected.
Code ReviewThis code review is in beta and may not always be helpful — use your judgment. Critical (1)
Warnings (1)
Suggestions (1)
ConventionsNo convention issues found. Style Guide ReviewNo style-guide issues found. CommandsOnly codeowners can run commands. Post a comment with the command to trigger it.
|
07ff037 to
8bf0781
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automates daily synchronization of AI Gateway catalog model files from the Unified Catalog API. The workflow uses
cloudflare-docs-botto open or refresh a pull request when catalog changes are detected, and closes an obsolete catalog pull request when the source matchesproductionagain.The catalog fetcher rejects malformed detail responses and empty catalogs before replacing the existing catalog, omits
schemawhen the API returnsnull, and reports model-specific failures with a 30-second request timeout.Required configuration
Configure the
AI_MODEL_CATALOG_ACCOUNT_IDandAI_MODEL_CATALOG_API_TOKENActions secrets. The workflow reuses the existingcloudflare-docs-botGitHub App credentials.Validation
pnpm --config.verify-deps-before-run=false run test(137 tests)pnpm --config.verify-deps-before-run=false run syncpnpm --config.verify-deps-before-run=false exec eslint bin/fetch-catalog-models.tspnpm --config.verify-deps-before-run=false run format:core:checkgit diff --checkThe live API fetch was not run locally because the catalog API token is only available through Actions secrets. Full type-check and lint remain blocked by existing generated
skills/turnstile-spinerrors unrelated to this change.