Skip to content

fix(platform): show the real reason when a queued deploy is refused - #908

Open
Brooooooklyn wants to merge 1 commit into
mainfrom
fix/admission-race-message
Open

Brooooooklyn wants to merge 1 commit into
mainfrom
fix/admission-race-message

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Summary

When a queued deploy is refused at the last check, the deploy stream now shows the real reason (for example "Zero Trust protection for this project is not ready … then retry") instead of always saying "Admitted deployment is no longer authorized or valid".

How it was found

Found during a live end-to-end run of a self-hosted platform while testing the security-audits work (PR #886). The bug is not part of that feature: it is in the existing durable deploy path, so it gets its own PR.

In the test, a project was flipped to public with void project zero-trust public while a void deploy was still waiting for admission. The flip won the race, as expected. The deploy then failed, which is also expected, but the stream said:

■ Admitted deployment is no longer authorized or valid

The user cannot tell from this that a plain retry is the fix. A retry right after did succeed.

Repro

  1. On a platform with Zero Trust enabled, protect a project.
  2. Start void deploy for that project.
  3. While it waits for admission, run void project zero-trust public for the same project.
  4. Watch the deploy stream.
Message on step authorization
Expected Zero Trust protection for this project is not ready: The project public exception is still reconciling. … then retry.
Actual Admitted deployment is no longer authorized or valid

The same happens for any other refusal at run time, such as a build that was canceled while its deploy sat in the queue ("This build is no longer active. Start a new build to deploy the current version.").

Root cause

void deploy ──► admit (200, receipt) ──► queue ──► executeQueuedDeployment
                                                     │
                                                     ▼
                                     handleManifestOnlyDeploy (in-process)
                                                     │
                                        409 {error, message}   ◄── real reason here
                                                     │
                                                     ▼
                         status != 204 ──► body never read
                                       ──► "Admitted deployment is no longer authorized or valid"

platform/packages/api/src/routes/deploy.ts:585-607 (on main) runs the deploy handler again for the queued work. When the handler answers anything other than 204, the code marks the deployment failed and appends an error event with a fixed text. It never reads the response body, so the handler's own message (or error) is dropped.

Fix

  • platform/packages/api/src/routes/deploy.ts: new rejectedAdmissionReason() reads the handler's response when it is JSON, up to 8 KiB, and takes message, or error when there is no message. The result (cut to 4096 characters) is used both for the deployment's error_message and for the error event. If the body is missing, not JSON, too large, or has neither field, the old generic text is still used.
  • The step stays authorization and the status stays failed, so nothing else in the flow changes.
  • Non-JSON bodies (such as an NDJSON receipt stream) are not read; their stream is canceled.

These messages are the same ones a direct (non-queued) deploy already returns to the CLI, so no new information is exposed.

Tests

platform/packages/api/test/integration/deployment-execution.test.ts:

  • New: "reports the Zero Trust reason when protection changes while a deploy waits". Admits a deploy, then makes the Zero Trust routing check report "public exception is still reconciling" before the queued run. Checks that error_message and the last error event carry the Zero Trust reason with the retry hint.
  • Extended: "rejects a queued deployment whose bound build was revoked before execution" now checks that the message is the handler's "This build is no longer active…" text and that the step is authorization.

Both fail on main (they get the generic text) and pass with this change. Ran:

  • vp test run --project 'platform-api-integration*' platform/packages/api/test/integration/deployment-execution.test.ts: 55 passed
  • vp run --filter ./platform/packages/api typecheck
  • vp check: format and lint pass; the only errors are missing generated tsconfig files in playgrounds that this worktree did not build
  • vp run test: still running when this PR was opened; CI covers the full suite

🤖 Generated with Claude Code

When the deploy handler refused an admitted deploy at run time (for
example a Zero Trust flip that won the race, or a canceled build), the
stream always said "Admitted deployment is no longer authorized or
valid". Read the handler's small JSON body and pass on its message,
keeping the generic text as a fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T22:15:37.974737Z c87a3ad PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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