fix: harden auto-format workflow and auto-regenerate OpenAPI snapshots#2026
fix: harden auto-format workflow and auto-regenerate OpenAPI snapshots#2026nick-inkeep merged 2 commits intomainfrom
Conversation
Auto-format race condition: Add 3-layer defense against branch deletion during workflow execution. When a PR is merged while auto-format is running, the branch gets deleted and git fetch/push fails. Now: (1) check PR state before starting, (2) continue-on-error on checkout with graceful exit, (3) git ls-remote guard before push/retry. OpenAPI snapshot drift: Add lint-staged hook to auto-regenerate the OpenAPI snapshot when route files or openapi.ts change. Developers no longer need to manually run `pnpm openapi:update-snapshot` — it happens automatically on commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
This PR implements a well-designed solution to two orthogonal CI/CD reliability problems. The 3-layer defense against the auto-format race condition (PR state check → checkout fallback → push guard) is robust, and the lint-staged hook for OpenAPI snapshot auto-regeneration is a sensible DX improvement with appropriately scoped file matching.
🔴❗ Critical (0) ❗🔴
None
🟠⚠️ Major (0) 🟠⚠️
None
🟡 Minor (0) 🟡
None
💭 Consider (1) 💭
💭 1) .github/workflows/auto-format.yml:52-56 Misleading step name
Issue: The step "Exit if checkout failed" doesn't actually exit the workflow — it only emits a GitHub notice annotation.
Why: The name implies termination, but execution continues (relying on conditional guards in subsequent steps). This works correctly but could confuse future maintainers.
Fix: Rename to "Log checkout failure" for accuracy, or add exit 0 if early termination semantics are preferred.
Refs: auto-format.yml:52-56
✅ APPROVE
Summary: Clean implementation with thoughtful defensive patterns. The 3-layer defense (PR state check, checkout fallback, branch existence verification) handles the race condition gracefully, and the lint-staged automation reduces manual steps without adding excessive overhead. Ship it! 🚀
Discarded (7)
| Location | Issue | Reason Discarded |
|---|---|---|
auto-format.yml:44 |
Actions pinned to mutable tags | Pre-existing pattern across all repo workflows, not introduced by this PR |
auto-format.yml:26-39 |
Good PR state check pattern | Positive feedback, not an actionable issue |
auto-format.yml:119-135 |
Good branch existence verification | Positive feedback, not an actionable issue |
package.json:104-106 |
Glob pattern syntax verification | Author confirmed testing in PR description; low confidence concern |
package.json:105 |
Bash wrapper for lint-staged | Standard pattern, not an issue |
package.json:104-106 |
Good DX improvement | Positive feedback, not an actionable issue |
auto-format.yml:22-23 |
Permissions appropriately scoped | Positive feedback, not an actionable issue |
Reviewers (2)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
pr-review-devops |
8 | 0 | 1 | 0 | 0 | 0 | 7 |
pr-review-standards |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 8 | 0 | 1 | 0 | 0 | 0 | 7 |
Rename "Exit if checkout failed" to "Log checkout failure" since the step only emits a notice annotation — it doesn't terminate the workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
Delta Review
This is a re-review scoped to changes since the last automated review. The delta consists of a single commit (1dec593f) that renames a workflow step from "Exit if checkout failed" to "Log checkout failure".
Prior feedback status: ✅ Addressed — the rename directly resolves the only "Consider" item from the previous review, which noted the misleading step name.
🔴❗ Critical (0) ❗🔴
None
🟠⚠️ Major (0) 🟠⚠️
None
🟡 Minor (0) 🟡
None
💭 Consider (0) 💭
None — the prior Consider item has been addressed by this commit.
✅ APPROVE
Summary: The delta addresses the only feedback from the prior review. The step name now accurately reflects its behavior (logging, not exiting). No new issues identified. Ship it! 🚀
Reviewers (0)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
| orchestrator (self-review) | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
Note: Subagent reviewers were not dispatched for this delta review because the change is trivial (1-line rename addressing prior feedback) with no functional impact.
Summary
Problem
Two recurring CI/CD flakiness issues identified across recent PRs:
1. Auto-format race condition (PRs #2005, #2012)
When a PR is merged within seconds of the auto-format workflow triggering, GitHub deletes the PR branch. The workflow's
git fetch/git pushthen fails because the branch no longer exists on the remote.2. OpenAPI snapshot drift (PRs #2009, #2010, #2011)
Developers change API route summaries/tags/paths but forget to run
pnpm openapi:update-snapshot. The snapshot test catches this in CI, but the manual step is easy to forget.Changes
Auto-format workflow (
.github/workflows/auto-format.yml)3-layer defense against branch deletion during workflow execution:
gh pr viewbefore doing any work; skips if PR is already merged/closedcontinue-on-error: trueon checkout with graceful exit if it failsgit ls-remote --exit-codebefore push and before each retry to verify branch still existsOpenAPI snapshot auto-update (
package.json)openapi.ts+createApp.tsopenapi:update-snapshotand stages the resultTest plan
🤖 Generated with Claude Code