Skip to content

feat(deploy-approvals): a new request supersedes the branch's older pending ones - #237

Open
ndbroadbent wants to merge 1 commit into
mainfrom
nathan/supersede-pending-deploy-approvals
Open

ndbroadbent wants to merge 1 commit into
mainfrom
nathan/supersede-pending-deploy-approvals

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Problem

A CI pipeline that raises a deploy approval request for every passing build leaves a pending request behind for each push to a branch. Each stays open for DEPLOY_APPROVAL_PENDING_MAX_AGE (7 days), so the open list fills with stale requests and an approver (on the web UI, the CLI or a phone) can't tell which one matters.

Change

  • Supersede: creating a request expires the older pending requests for the same app, branch and target API token (SupersedeDeployApprovalRequests). It runs in one transaction under the audit chain lock, with an audit event per request: deploy_approval_request.expire by system, with reason: superseded and superseded_by (the new request's ID). Approved requests are never touched, since one may be deploying. A request with no branch supersedes nothing. If superseding fails, the new request still succeeds and the error goes to the log and Sentry; the older requests then expire by age.
  • Shorter default: DEPLOY_APPROVAL_PENDING_MAX_AGE defaults to 24h instead of 168h.
  • ExpireDeployApprovalRequests and the new query share one helper for the transaction, lock and audit appends, and one row scanner.
  • Docs: the deploy approvals overview, workflow table and environment variable reference.

Testing

  • DB tests: only the older pending request on the same app, branch and token expires, and approved requests, other apps, other branches and other tokens stay as they are. A request with no branch supersedes nothing. A failed audit append expires nothing.
  • Handler test: a second request on a branch expires the first, with the superseded audit details, and a request on another branch stays pending.

Show it working
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…ending ones

CI raises a deploy approval request for every passing build, so a busy
branch left a pending request behind for each push, each open for a week,
and an approver couldn't tell which one mattered.

- A new request expires the older pending requests for the same app,
  branch and target API token, in one transaction with an audit event for
  each (deploy_approval_request.expire, reason superseded, superseded_by
  the new request). Approved requests are left alone. A failure doesn't
  fail the new request: the older ones expire by age.
- DEPLOY_APPROVAL_PENDING_MAX_AGE defaults to 24 hours instead of 7 days.
- ExpireDeployApprovalRequests and the new SupersedeDeployApprovalRequests
  share the transaction, lock and audit append.
@deepsource-io

deepsource-io Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 61363f9...9e38d40 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Dec 3, 2026 2:57a.m. Review ↗
Go Dec 3, 2026 2:57a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant