chore: automate AI model catalog sync#32057
Draft
adriandlam wants to merge 1 commit into
Draft
Conversation
dddc10a to
143b631
Compare
143b631 to
07ff037
Compare
Contributor
Review
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
### Warnings (2)
#### CR-e3e35afb0bb9 · Automated PR falsely attests to style guide compliance
- **File:** `.github/workflows/sync-ai-model-catalog.yml` line 140
- **Issue:** The generated pull request body hard-codes '- [x] The change adheres to the [documentation style guide]...', marking the style-guide checklist as complete even though the bot cannot verify adherence.
- **Fix:** Change the checkbox to unchecked ('- [ ]') so human reviewers actually confirm style-guide compliance before merging.
#### CR-6fdc960868be · Permissive type guard
- **File:** `bin/fetch-catalog-models.ts` line 100
- **Issue:** `isCatalogModel` only validates `model_id`, `name`, `description`, and `metadata`, then casts to the full `CatalogModel` shape. It does not check required fields such as `examples`, `tags`, `task`, `context_length`, or the `private` flag.
- **Fix:** Validate the full required shape in `isCatalogModel`, or validate the JSON output against a schema after writing, so malformed catalog responses cannot silently produce invalid model files.
### Suggestions (1)
#### CR-cd136f5b21f2 · Commit bypasses pre-commit hooks
- **File:** `.github/workflows/sync-ai-model-catalog.yml` line 109
- **Issue:** The commit command uses '--no-verify', which skips the repository's pre-commit hook (prettier/lint-staged and CRLF normalization) for the staged catalog files.
- **Fix:** Remove '--no-verify' unless there is a specific hook that must be skipped, and rely on the earlier validation steps.
Code ReviewThis code review is in beta and may not always be helpful — use your judgment. Warnings (2)
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.
|
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 run test:prebuild(116 tests)pnpm run syncpnpm exec eslint bin/fetch-catalog-models.tspnpm exec prettier --check bin/fetch-catalog-models.ts .github/workflows/sync-ai-model-catalog.ymlgit diff --checkThe live API fetch was not run locally because the catalog API token is only available through Actions secrets.