Repository navigation
Fix realtime token mint failure diagnostics - #9102
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2ab40748d
ℹ️ 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".
| statusCode: httpResponse.statusCode, | ||
| payload: payload, | ||
| provider: provider) | ||
| throw RealtimeTokenMintError(statusCode: httpResponse.statusCode, healthError: healthError, payload: payload) |
There was a problem hiding this comment.
Preserve mint errors across auth retry
When the first mint attempt returns 401, the auth-refresh path recursively calls performRealtimeMintRequest; if that retry then gets any structured mint failure, this newly thrown RealtimeTokenMintError is not caught by the retry wrapper and falls into the generic catch, which rethrows CredentialHealthError.backendTransient. That discards payload.reason, backendRoute, upstreamStatusCode, and retryability, so common expired-auth-then-provider-failure cases still lose the diagnostics this change is trying to preserve.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
5 issues found across 8 files
Confidence score: 3/5
- In
desktop/macos/Desktop/Sources/APIClient.swift, the 401 refresh-retry error path can dropRealtimeTokenMintErrordetails when the retried call fails, so non-2xx mint failures lose structured diagnostics and become harder to classify/support — preserve and rethrow the structured mint error in the retry catch before merging. - In
desktop/macos/Backend-Rust/src/routes/realtime.rs, Gemini error parsing prefers numericerror.codeand then loses it viaas_str()without falling back toerror.status, which can strip provider-specific failure codes and blur quota/auth handling — parse string/numeric forms safely and fall back toerror.statuswhen needed. - Across
desktop/macos/Desktop/Sources/FloatingControlBar/RealtimeHubController.swiftanddesktop/macos/Backend-Rust/src/routes/realtime.rs, provider metadata is still omitted in some structured responses (provider_code/code, andMissingKey(p)provider name), so incidents remain less actionable even though payload fields exist — include these fields in emitted JSON/UI logging to complete end-to-end diagnostics. desktop/macos/Desktop/Sources/APIClient.swiftcurrently exposes only message text inRealtimeTokenMintError.errorDescription, omitting status/reason; merged as-is, logs and surfaced errors may hide key context during outages — include HTTP status and structured reason in the description formatting.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Addressed the review comments in f581aa9:\n\n- Preserve RealtimeTokenMintError across the 401 refresh retry path so structured mint failures are not flattened.\n- Include provider_code in desktop diagnostics and pass it from realtime mint failures.\n- Include provider on missing-key backend errors.\n- Prefer string provider status/code values over numeric HTTP-ish codes when parsing upstream error bodies, preserving values like RESOURCE_EXHAUSTED.\n- Add status/reason/code to RealtimeTokenMintError.errorDescription for clearer logs.\n\nValidation rerun locally:\n- cd desktop/macos/Backend-Rust && cargo fmt && cargo test routes::realtime\n- xcrun swift test -c debug --package-path desktop/macos/Desktop --filter 'APIClientRoutingTests/testRealtimeMintStructuredFailurePreservesDiagnostics'\n- xcrun swift test -c debug --package-path desktop/macos/Desktop --filter 'DesktopDiagnosticsManagerTests/testTokenMintFailureIncludesHttpStatusWhenKnown'\n- git diff --check\n- pre-push fast checks passed during push |
Summary
Fixes #9080 by preserving safe, actionable realtime token-mint failure reasons from the desktop Rust backend through the macOS health event.
Root cause:
CreateAuthTokenRequestbody now wraps settings underauthToken, matching Google Live API docs.unknown/ generic transient failures, often without provider route, provider status, or retryability, so the July 5 failures could not be separated into provider auth/quota/outage/rejected-request/config cases.What changed:
/v2/realtime/sessionnow returns structured safe mint error JSON:reason,backend_route,provider, providercode,upstream_status_codewhen available, andretryable.APIClient.mintRealtimeTokenpreserves those fields viaRealtimeTokenMintErrorinstead of erasing them in a generic catch.RealtimeHubControllerrecords structured mint diagnostics for warm and barge-in token mint phases while preserving existing failover/fallback behavior.DesktopDiagnosticsManagerincludes the new safe fields inrealtime_token_mint_failedhealth snapshots.Verification
cargo fmtcargo test routes::realtimexcrun swift test -c debug --package-path Desktop --filter 'APIClientRoutingTests/testRealtimeMintStructuredFailurePreservesDiagnostics'xcrun swift test -c debug --package-path Desktop --filter 'DesktopDiagnosticsManagerTests/testTokenMintFailureIncludesHttpStatusWhenKnown'Note: a broader filtered Swift run of
APIClientRoutingTests|DesktopDiagnosticsManagerTestsexposed an unrelated existing failure inAPIClientRoutingTests.testDeleteConversationRoutesToPython: the test expects?cascade=true, while currentdeleteConversationsends/v1/conversations/conv-456. The new realtime mint test and diagnostics test both pass individually.