#2944

fix(gateway): the relay deploy reports why it can't read the maintenance switch

OpenDanielButler1wants to merge intofrom

What changed

apps/api/scripts/deploy-realtime.ps1 now tells "the maintenance switch is off" apart from "the switch couldn't be read":

  • It says the switch is off only when wrangler reports 404: Not Found for the key.
  • Any other failure, such as a 401 or 403 from a token without Workers KV read access or wrangler missing, stops the deploy with wrangler's own error, colour codes removed.
  • Wrangler's stderr no longer stops the script before its exit code is read, under both PowerShell 7 (CI) and Windows PowerShell.

Why

The first non-initial relay deploy, run 41042458630 on 2026-10-30, stopped with "The realtime maintenance switch is off". The switch was on. Read with wrangler locally just before and after the run, it gave {"enabled":true,"since":"2026-10-30T10:32:45Z",...}.

The script ran wrangler with 2>$null and treated any failure as "off", so the real error was thrown away. This check had never run in CI: the only earlier relay deploy used -Initial, which skips it. The likely cause is that the CI Cloudflare token can't read Workers KV, since gateway deploys only need Workers access. That's inferred, not confirmed: the token's permissions can't be seen from here. This PR makes the next run say exactly what failed.

How

  • Capture wrangler's output with 2>&1 and the error preference relaxed just around the call, then restore Stop.
  • Take the JSON line as the switch value, and match the 404 on the /values/<key> URL exactly. A broad "not found" match would treat Command "wrangler" not found as "switch off" (found while testing).

Before and after

Method: the new block run with Windows PowerShell 5.1 against the real KV namespace (read-only kv key get), in four cases.

CaseBeforeAfter
Switch onDeploy continuesDeploy continues (ON: {"enabled":true,...})
Key never set"switch is off""switch is off"
Token rejected (401)"switch is off""Could not read ... 401: Unauthorized"
wrangler not installed"switch is off""Could not read ... 'wrangler' is not recognized"

Verification

  • The four cases above, run locally with Windows PowerShell 5.1. The 401 case used a deliberately invalid token.
  • Not verified: PowerShell 7 locally (pwsh isn't installed on this machine); CI runs the script with pwsh. The real cause in CI is shown on the next workflow run after merge.
  • The realtime maintenance switch is still on (since 10:32:45Z) with 0 live sessions, so the relay deploy can rerun as soon as this merges.

Model: Claude Opus 5.5 (effort unknown) · Harness: Claude Code in T3 Code

🤖 Generated with Claude Code

Activity

11
vercel[bot]16h ago

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated
phaseo SkippedOct 30, 2026 10:55am UTC

coderabbitai[bot]16h ago

WARNING

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c7a76edd-3359-40b3-8419-e84c843f6f64
Commits

Reviewing files that changed from the base of the PR and between 0a93ac0b688d5a292e88c718617b9463949d8532 and 2c8f78338484d74e1b3dbd2680d25c9f4cb8462c.

Files selected for processing: 1
  • apps/api/scripts/deploy-realtime.ps1
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

chatgpt-codex-connector[bot]16h ago

Codex Review Summary

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

ReviewStatusCommitReview trigger
📝 Code Review✅ Completed 2026-10-30T10:51:05.375641Z43ace07PR 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.

github-actions[bot]16h ago

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None
chatgpt-codex-connector[bot]reviewed16h ago
chatgpt-codex-connector[bot]16h ago

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43ace076d2

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

chatgpt-codex-connector[bot]reviewed16h ago
DanielButler1reviewed16h ago
DanielButler1reviewed16h ago