fix(ci): require explicit steps and prod confirmation for down migrations - #1216
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 40 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe database-migration workflow is hardened against accidental production schema destruction by requiring explicit authorization for rollback operations. A new ChangesDatabase Migration Rollback Safety
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested Labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
64916b7 to
0880a3b
Compare
0880a3b to
4e46ba6
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
4e46ba6 to
ae12832
Compare
Adversarial-review passReviewed against the threat model (down migrations are destructive; the prior code echoed a warning while still setting In-scope fix pushed (force-push on
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
ae12832 to
b9c03ba
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
b9c03ba to
6f89acf
Compare
…ions direction=down with the default steps=0 ran 'migrate down -all' in all three cloud jobs, dropping the entire schema, and the validate job's prod guard only echoed a warning while still setting is_safe=true, promising a confirmation step that did not exist. - validate now rejects direction=down unless steps is an explicit positive integer, and fails the job instead of skipping silently - prod down migrations additionally require typing 'rollback-prod' in the new 'confirm' dispatch input - the three migrate jobs no longer have a 'down -all' branch; they fail loud if steps is missing or non-positive (defense in depth) - free-form inputs are passed to the shell via env vars Validated with actionlint and a local simulation of the validate logic against the failing scenario (prod, down, steps=0, no confirm): the pre-fix logic yields is_safe=true, the post-fix logic fails validation, and legitimate up/down flows still pass. Closes #1173
Pin actions/setup-go to SHA 4a3601...c1c06c (v6.4.0) in all three migrate jobs (AWS, GCP, Azure); the pre-existing @v5 tag was unpinned, inconsistent with every other workflow in the repo. Update .github/workflows/README.md to accurately describe the down- migration guards introduced in this PR: replace the stale "warns on prod down migrations" bullet with the actual fail-closed behavior (explicit steps required, rollback-prod confirmation for prod), and add a prod-down example command showing the confirm input.
6f89acf to
644bd59
Compare
|
@coderabbitai review |
|
Merge-prep bot: rebased onto main (73166c2). Gates: build=0 (no Go touched), gocyclo=n/a, lint=n/a. Workflow change verified: validate job now exits 1 on bad inputs, down-all branch removed from all 3 migrate jobs (AWS/GCP/Azure), setup-go SHA-pinned to v6.4.0, required-check job names unchanged. No existing deploy jobs broken. |
✅ Action performedReview finished.
|
|
Merged to main (rebased onto current main, CLEAN + all CI green; closes #1173). CI hardening: validate steps now exit 1 on bad inputs, destructive down-all removed from 3 migrate jobs (guarded), setup-go SHA-pinned; required-check names unchanged. The earlier Integration failure was a shared testcontainer-quota infra flake (migrations passed to v83), cleared on re-run. |
Problem
Closes #1173 (review finding INF-03, P2).
In
.github/workflows/database-migration.yml, thestepsdispatch input defaults to 0 ("0 = all"). In all three cloud jobs,direction=downplussteps=0ranmigrate ... down -all, dropping the entire schema. The validate job's prod+down branch commented "we don't auto-fail, but require manual confirmation" yet only echoed a warning and still setis_safe=true; no confirmation input existed anywhere in the workflow. An operator pickingdirection=downand leavingstepsat its default would destroy every table in the target database, including prod.Fix
direction=downunlessstepsis an explicit positive integer (^[1-9][0-9]*$), and fails the job (exit 1) instead of silently skipping downstream jobs, so a blocked run is visibly red.rollback-prodin a newconfirmdispatch input (same pattern as cleanup-staging's typeddestroyconfirmation). The phantom-guard comment is gone; the guard is real.down -allbranch is removed from all three migrate jobs (AWS/GCP/Azure); they fail loud ifstepsis missing or non-positive, so even a future validate regression cannot reachdown -all.confirminput (and the other inputs used by the new checks) are passed to the shell viaenv:rather than inline interpolation.workflow_call(which defines neitherstepsnorconfirm) is unaffected forupand now fails validation fordown, which is the safe behavior; no caller in the repo uses this workflow today.Test evidence
actionlinton the modified workflow: clean.environment=prod,direction=down,steps=0, emptyconfirm): the pre-fix logic reproduces the bug (is_safe=true, job would rundown -all); the post-fix logic setsis_safe=falseand the job guard blocks. Legitimate flows still pass: staging down withsteps=1, prod down withsteps=2+confirm=rollback-prod, prod up withsteps=0(all), andworkflow_callup with empty steps. A wrong confirm string is rejected.Summary by CodeRabbit