Repository navigation
fix(ci): generate the Postman collection deterministically, only on main - #472
Conversation
openapi-to-postmanv2 gives every item a random UUID and fakes example values with Math.random, so each run rewrote the collection. The bot ran on every branch push that touched docs/openapi.json and committed the result with [skip ci], which became the PR head and left required checks unreported. tools/generate-postman.mjs seeds the faker and derives item and response ids from their names in the tree, so the same spec always yields the same file. The workflow commits only on main, where a GITHUB_TOKEN push starts no new run, so it drops [skip ci]. Pull requests that change the generator run it and its tests without committing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ator Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Shadow risk calibration
Calibration result: agreement. Shadow risk never blocks or enables merge. Keep it in observation mode until roughly 50 pull requests have human-reviewed labels, then calibrate before considering any policy use. |
| } | ||
| }; | ||
| walk(collection.item); | ||
| assert.equal(ids.length, 453); |
There was a problem hiding this comment.
Spec changes stop collection updates
Adding or removing an endpoint or response changes the number of generated IDs, so assert.equal(ids.length, 453) fails even when every ID is unique. On a spec-only push to main, this stops the workflow before the bot can commit the updated collection. Replace the fixed count with checks that allow the spec to grow while still checking that the expected entries have unique IDs.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tools/postman-generation.test.mjs
Line: 90
Comment:
**Spec changes stop collection updates**
Adding or removing an endpoint or response changes the number of generated IDs, so `assert.equal(ids.length, 453)` fails even when every ID is unique. On a spec-only push to `main`, this stops the workflow before the bot can commit the updated collection. Replace the fixed count with checks that allow the spec to grow while still checking that the expected entries have unique IDs.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
💡 Codex Review
When a main-branch OpenAPI change does not already include the regenerated collection, deploy_postman.yml runs for the original push and checks out that stale SHA, while this bot push uses GITHUB_TOKEN and therefore does not trigger another workflow run, as the preceding comment acknowledges and GitHub documents. Consequently, the newly committed collection is never published to Postman; dispatch the deployment after this successful push or perform deployment in this workflow.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| }; | ||
| walk(collection.item); | ||
| assert.equal(ids.length, 453); |
There was a problem hiding this comment.
Derive the expected ID count from the generated tree
When a legitimate OpenAPI change adds or removes a request, folder, or response, generation changes the number of IDs, so the main-only workflow fails here before its commit step and leaves the collection stale. Count all traversed entries dynamically and compare that count with ids.length rather than pinning the current generated size of 453.
AGENTS.md reference: AGENTS.md:L30-L36
Useful? React with 👍 / 👎.
Cause
generate_postman.ymlran on every push that toucheddocs/openapi.json, including PR branches that merge main.openapi-to-postmanv2gives each item and response a random UUID and fills example values withMath.random. Two runs on the same spec differed in 316 lines. So the collection always changed, and the bot always committed it with[skip ci]. That commit became the PR head, and required checks never reported on it.Fix
tools/generate-postman.mjswraps the converter with the same options. It seeds the faker's random source and derives each item and response ID from its folder and request names. The same spec now gives a byte-identical file. A request keeps its ID when only its body changes.openapi-to-postmanv2is now an exact root devDependency (6.3.0, the version the workflow already installed), sonpm ciinstalls it.main. AGITHUB_TOKENpush starts no new run, so[skip ci]is gone. Pull requests that change the generator, its test, the workflow, or the lockfile run generation and tests without committing.tools/postman-generation.test.mjschecks that two runs are identical and match the committed file, and that all 453 item and response IDs are unique.node tools/generate-postman.mjs.Verification
node tools/generate-postman.mjstwice in separate processes, then compared the outputs withcmp. They are identical.--checkpasses on the committed file.node --test tools/postman-generation.test.mjspasses 5 of 5 tests.vp run check,vp run test, andnpm run check:agent-trustpass.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Fix the fixed ID count before merging so ordinary spec changes do not stop automatic collection updates.
Fix with agent prompt
Summary
Adds a generator that seeds example values and derives stable IDs from request and response names.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Matching push to main or pull request] --> B[Install dependencies] B --> C[Generate collection] C --> D[Run generation tests] D --> E{Tests pass?} E -->|No| F[Stop without committing] E -->|Yes| G{Push to main?} G -->|Yes| H[Commit and push changed collection] G -->|No| I[Finish without writing to branch]Reviews (1) · Last reviewed commit: "chore: regenerate the Postman collection..." · Reviewed by Greptile