fix(rollback): guard unsafe rollback requests#243
Draft
aparajon wants to merge 1 commit into
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds guardrails to ensure SchemaBot rollback requests fail closed unless the requested apply can be proven safe to target (latest completed apply for the scoped database/environment, and backed by stored original schema), and introduces a rollback-specific rejection message for those safety-gate denials.
Changes:
- Added
ValidateRollbackSourceApplyguardrails in the API layer to reject unsafe/ambiguous rollback targets. - Updated the webhook rollback flow to use the new guardrails and post a dedicated “Rollback Not Allowed” message on rejection.
- Added tests covering the new rejection template and rollback guardrail scenarios.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/webhook/templates/rollback.go | Adds a rollback-specific rejection comment renderer and data struct. |
| pkg/webhook/templates/rollback_test.go | Adds coverage for the new rollback rejection template and whitespace checks. |
| pkg/webhook/rollback.go | Routes rollback requests through the new guardrails; acquires/releases locks around rejected planning paths; posts rollback-specific rejection comments. |
| pkg/api/handlers_test.go | Extends test stores/mocks to support the new guardrail logic and adds guardrail-focused tests. |
| pkg/api/control_handlers.go | Implements ValidateRollbackSourceApply and supporting helpers used by webhook + HTTP rollback-plan handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0e52db2 to
a47430c
Compare
a47430c to
fdfdfae
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
apply_id+environment; the database is derived from the stored apply instead of accepted from users.-don rollback and rollback-confirm PR commands so rollback flows are not database-scoped through compatibility flags.This keeps self-service rollback fail-closed while the selected-apply rollback planner is split out into follow-up work.
Generated with Amp.