fix(relay): preserve provisioning failure stage in client errors #14581
main fromrefs/pull/14581/head·merged by juliusmarminge View on GitHubT3 Connect discards the failed provisioning stage when translating ManagedEndpointProvisioningFailed into the client-facing 503. Web, desktop and mobile therefore cannot distinguish a tunnel failure from other provisioning failures.
Carry the server-defined stage as optional provisioningStage in the existing error, then append it in the shared client presenter. Keep the reason and trace ID, accept older relay responses without the field and future stage names, and select only the public stage rather than forwarding provider causes or resource identifiers.
Retained @ECuteri's original production fix after a fresh implementation run independently found it already minimal. Preserved the original commits and merged current main. Rebuilt the HTTP regression with the current handler layers and reduced six PR cases to three.
Closes #14580. Related to #14070.
Verification at 61174caf2b:
- Three focused suites: 48 cases before (47 passed, one broken removed-clientApi fixture) → 45 passed after. Separately removing each production layer produces a behavioral failure.
- Relay, contracts and client-runtime typechecks passed; targeted formatting and diff checks passed. Lint passed with one pre-existing unused import warning.
- Actual local TCP HTTP request through the current relay handler returned 503 with ensure-tunnel and the matching failure-span trace ID; decoding and shared presentation displayed the stage. Exact response equality excludes the injected synthetic private provider cause and tunnel ID.
- Compatibility probe against the actual pre-change error class confirmed older clients ignore the new field. Current clients preserve absent and future stage names.
Before/after regressions, compatibility and live HTTP proof
No visual layout changed. The local HTTP proof injects authentication and the provisioning failure; it creates no Cloudflare resources. No hosted provisioning, real accounts, browser UI, macOS/Windows, iOS/Android or packaged Electron client was verified. This improves web/desktop/mobile diagnostics, not provisioning or recovery policy. The server's own headless self-link warning still uses the contract's existing reason-only message; that separate presenter is unchanged.
A relay deployment is required before updated clients can receive the stage. A relay operator must still inspect the actual traces and remedy the hosted failure; this does not resolve the incident in #14070. One fresh full-diff review round by Claude Opus 5.5 and Codex GPT-6 Sol found no code blockers; both independently passed all 45 focused tests. Current-head build/typecheck, lint, general tests, release smoke and all eight server shards passed; configured correctness and approvability checks passed. The first web CI job failed the unchanged WorkflowOpeningBlock syntax-highlighting wait; its file passed locally (3/3), and failed CI jobs have been rerun. CodeRabbit reports review-budget exhaustion on this push, so its green status does not establish a fresh full review; the two independent full-diff reviews above cover this head. A canceled duplicate native-fingerprint run was superseded by a successful run on the same head. The CI rerun failed the same unchanged syntax-highlighting wait (8047 passed / 1 failed); this PR is not declared merge-ready.
Implementation review: Codex GPT-6.1 Sol in T3 Code; tests: Codex GPT-6 Astra; adversarial reviewers: Claude Opus 5.5 and Codex GPT-6 Sol.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
Approvability#
Verdict: Approved at
61174caMacroscope's review found this PR approvable — This is a narrow relay diagnostic fix that preserves the existing HTTP status and error reason while adding an optional provisioning stage. Backward compatibility and provider-secret exclusion are tested, with no product-default or static-analysis configuration changes.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Warning
Review limit reached#
Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.
Next included review available in 3 minutes.
View limit details
-
Limit details: You’ve used all 10 included reviews currently available.
Review configuration:
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
e7e2bee7-16f0-481c-a2d0-49e1867232f2
📥 Commits
-
Reviewing files that changed from the base of the PR and between c7723efc80bb734a9238bb2dd3257520bb80d793 and fcf6c97089547b9c8dba7fc466ad173d299709c3.
📒 Files selected for processing: 6
-
infra/relay/src/http/Api.test.tsinfra/relay/src/http/Api.tspackages/client-runtime/src/relay/errorPresentation.test.tspackages/client-runtime/src/relay/errorPresentation.tspackages/contracts/src/relay.test.tspackages/contracts/src/relay.ts
-
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
413142d6-a087-4a41-a3fc-c7c8393d9e0e
📥 Commits
-
Reviewing files that changed from the base of the PR and between 5cc99e1c23980d7995a13c47f969b47cb68ed1be and c7723efc80bb734a9238bb2dd3257520bb80d793.
📒 Files selected for processing (6)
-
infra/relay/src/http/Api.test.tsinfra/relay/src/http/Api.tspackages/client-runtime/src/relay/errorPresentation.test.tspackages/client-runtime/src/relay/errorPresentation.tspackages/contracts/src/relay.test.tspackages/contracts/src/relay.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
The relay now includes the failed managed-endpoint provisioning stage in the unavailable-link error response. The shared error contract accepts the optional field, and the client error message displays it when present. Tests cover HTTP response sanitization and compatibility with older responses.
Changes: Provisioning error details
Layer / File(s) Summary Add optional stage to error contract
packages/contracts/src/relay.ts,packages/contracts/src/relay.test.tsThe error schema accepts an optional provisioning stage. Tests check decoding when the field is missing or contains an unrecognized value. Propagate stage in relay response
infra/relay/src/http/Api.ts,infra/relay/src/http/Api.test.tsThe handler includes the provisioning failure stage in the unavailable-link response. The HTTP test checks the 503 response, client message, and omission of private failure details. Display stage in client error message
packages/client-runtime/src/relay/errorPresentation.ts,packages/client-runtime/src/relay/errorPresentation.test.tsThe client message includes the stage when present and retains the reason-only message when it is absent. Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
c7723-
This change adds the failed provisioning stage to link-failure errors and keeps older responses working. I found no merge-blocking risk. Clients only show the stage once the relay is deployed with this change.
Security architecture risk: ⚪ Minimal · up to
c7723-
The change exposes a server-defined stage label in an existing error response without expanding permissions or returning provider secrets or resource identifiers. Older responses remain supported. No material security risk was found in the changed behavior.
Retained concerns No architecture-level concerns identified.
Security review details
-
Security Blast Radius
- inferred — The added exposure is operational-stage information in an existing user-scoped linking failure response. The changed flow provides no new ability to access another environment, obtain a tunnel token, or control provider resources.
Trust Boundaries and Controls
- observed — The internal-to-client error boundary remains an explicit field selection rather than serialization of the provider error. Request data is not copied into provisioningStage; inspected provider failure sites assign literal stage labels independently of provider causes and resource identifiers.
Resilience and Maintainability Implications
- observed — The HTTP regression injects a provisioning failure containing a synthetic private tunnel ID and provider cause, then asserts the exact serialized 503 body and decoded client message. This protects the disclosure boundary against drift, but does not exercise production authentication, live allocation, or recovery.
-
Pre-merge checks:
4 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Docstring Coverage Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold. Passed checks: 4 passed-
Check name Status Explanation Linked Issues check PR #14581meets the coding requirements in directly linked issue#14580.Api.tscarries the bounded provisioningstageintoprovisioningStage. The contract makes this field optional. The client …Out of Scope Changes check The changes remain within issue #14580. The source changes implement stage propagation, optional contract decoding, and client presentation. The added tests verify HTTP behavior, compatibility, and sa…Title check The title clearly identifies the primary change: preserving the provisioning failure stage in client errors. It is concise and specific. Description check The description covers the problem, change, scope, linked issues, compatibility requirements, verification results, limitations, and deployment considerations. The Scope and approval section does not … Full details: Linked Issues check
-
Explanation
PR
#14581meets the coding requirements in directly linked issue#14580.Api.tscarries the bounded provisioningstageintoprovisioningStage. The contract makes this field optional. The client presenter appends the stage and preserves the existing reason. Contract tests cover older responses without the field and unknown stage values. HTTP tests cover 503 serialization and omission of provider secrets and identifiers. The reported focused test, lint, formatting, typecheck, and diff checks pass.
Full details: Out of Scope Changes check
-
Explanation
The changes remain within issue
#14580. The source changes implement stage propagation, optional contract decoding, and client presentation. The added tests verify HTTP behavior, compatibility, and sanitization. No change addresses provisioning policy, recovery behavior, or the separate hosted incident.
Full details: Description check
-
Explanation
The description covers the problem, change, scope, linked issues, compatibility requirements, verification results, limitations, and deployment considerations. The Scope and approval section does not include a clearly identified maintainer approval comment, but the focused fix and linked issue context are documented sufficiently.
-
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.Autopilot is currently an internal CodeRabbit preview.
-
juliusmarminge added labelsmacroscope-review
Note
Written by
claude-opus-5-5on behalf of MariaHi! We are cleaning up open PRs, and this one appears to have been created with an older model (
gpt-6). If this change is really important, we recommend rebuilding the PR with a newer model if possible.maria-rcks closed this
Note
Written by
claude-opus-5-5on behalf of MariaReopening, this was closed by mistake. Sorry for the noise!
maria-rcks reopened this
juliusmarminge assignedjuliusmarminge
Taking over this one. I’ll keep the original commits and PR, merge main, and rebuild the focused HTTP regression around the current handler layers. The optional stage, response mapping and shared presentation remain one diagnostic fix; live hosted provisioning will still need operator verification.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged thisc8e2407
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed