Repository navigation
fix(den-web): explain OAuth-start answers the browser cannot read - #4666
Conversation
When a member clicks Connect and den-api's OAuth-start answer never reaches the page (a cross-origin error response without CORS headers, or no response at all), the connection row and the sign-in popup only echoed the browser's "Failed to fetch". Wrap that pre-response failure in McpOAuthStartError with an "unavailable" HTTP status and a plain message, so the popup's Technical details render and the member is not told the provider was involved. Den's own timeout, cancel and re-authentication errors keep their meaning. Proof: - evals/specs/mcp-oauth-start-browser-readable-errors.test.ts asserts den-api answers preflights, successes, handshake 502s and 401s on connect/start with exactly one Access-Control-Allow-Origin for the trusted web origin, credentials allowed, and none for other origins. - evals/specs/mcp-oauth-start-unreadable-response.e2e.test.ts drives the Den web connections page through a fault proxy whose injected answer the browser may not read, asserts the readability message (not "Failed to fetch") and zero provider authorization requests, then clears the fault and asserts the same button starts provider sign-in. Registered as a local-lane journey because the proxy must sit in front of den-api before Den boots. This does not change or diagnose why a deployment's OAuth-start request returns an error; it makes that failure readable to the member.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
|
Second test evidence section (the sticky comment above holds the boundary spec; the publisher keeps one run per sticky comment). Screenshots stay local — no blob token used by request. Test evidence — the connections page explains an OAuth-start answer the browser could not read, then connects once it can — ✅ passedSHA 2395ec6 · engine v1 ✅ 0/2 screenshots passed · 2 assertions · 2 expectations passed · 0 failed · 0 pending
[world] den(local) · orgConnection("Synthetic calendar provider") · web(signed in) ℹ️ ASSERTION — 1. An unreadable OAuth-start answer is explained in plain wordsThe proxy answered /v1/mcp-connections/emc_01m228p957ewc9h64dfgrgxwf4/connect/start with an injected HTTP 502 the browser could not read; the connection row shows the readability message, not "Failed to fetch", and the provider received no authorization request.
ℹ️ ASSERTION — 2. A readable OAuth-start answer starts the provider sign-inWith the fault cleared the proxied OAuth-start request returned HTTP 200 and the synthetic provider received an authorization request; the readability message disappeared.
⚪ UNVALIDATED — 3. the connections page explains an OAuth-start answer the browser could not read, then connects once it can artifact 1
⚪ UNVALIDATED — 4. the connections page explains an OAuth-start answer the browser could not read, then connects once it can artifact 3
Test run created 2026-09-09T05:01:20.674Z · Source: |
…urrent catalog additions
|
Second test evidence section for head 74b8184 (the sticky comment holds the boundary spec run for the same head; the publisher keeps one run per sticky comment). Screenshots stay local — no blob token used by request. Supersedes the earlier e2e section for 2395ec6. Test evidence — the connections page explains an OAuth-start answer the browser could not read, then connects once it can — ✅ passedSHA 74b8184 · engine v1 ✅ 0/2 screenshots passed · 2 assertions · 2 expectations passed · 0 failed · 0 pending
[world] den(local) · orgConnection("Synthetic calendar provider") · web(signed in) ℹ️ ASSERTION — 1. An unreadable OAuth-start answer is explained in plain wordsThe proxy answered /v1/mcp-connections/emc_01m2295kh6egevwvfvrqyzfznq/connect/start with an injected HTTP 502 the browser could not read; the connection row shows the readability message, not "Failed to fetch", and the provider received no authorization request.
ℹ️ ASSERTION — 2. A readable OAuth-start answer starts the provider sign-inWith the fault cleared the proxied OAuth-start request returned HTTP 200 and the synthetic provider received an authorization request; the readability message disappeared.
⚪ UNVALIDATED — 3. the connections page explains an OAuth-start answer the browser could not read, then connects once it can artifact 1
⚪ UNVALIDATED — 4. the connections page explains an OAuth-start answer the browser could not read, then connects once it can artifact 3
Test run created 2026-09-09T05:09:41.803Z · Source: |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (74b81848a77d264e256a1854243c2c936751dc37). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
…cement so other lanes skip loudly
|
Second test evidence section for head 8bb5739 (the sticky comment holds the boundary spec run for the same head; the publisher keeps one run per sticky comment). Screenshots stay local — no blob token used by request. Supersedes the earlier e2e sections. Note: the CI Product journeys run is withheld for this PR because it touches Test evidence — the connections page explains an OAuth-start answer the browser could not read, then connects once it can — ✅ passedSHA 8bb5739 · engine v1 ✅ 0/2 screenshots passed · 2 assertions · 2 expectations passed · 0 failed · 0 pending
[world] den(local) · orgConnection("Synthetic calendar provider") · web(signed in) ℹ️ ASSERTION — 1. An unreadable OAuth-start answer is explained in plain wordsThe proxy answered /v1/mcp-connections/emc_01m229f5ttemdaqs9h37q88nsk/connect/start with an injected HTTP 502 the browser could not read; the connection row shows the readability message, not "Failed to fetch", and the provider received no authorization request.
ℹ️ ASSERTION — 2. A readable OAuth-start answer starts the provider sign-inWith the fault cleared the proxied OAuth-start request returned HTTP 200 and the synthetic provider received an authorization request; the readability message disappeared.
⚪ UNVALIDATED — 3. the connections page explains an OAuth-start answer the browser could not read, then connects once it can artifact 1
⚪ UNVALIDATED — 4. the connections page explains an OAuth-start answer the browser could not read, then connects once it can artifact 3
Test run created 2026-09-09T05:14:55.135Z · Source: |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (8bb573987d45f46bc305c7bcb47e51e450cced8c). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
Warm the browser's preflight cache first with den-api's own readable handshake 502 (provider taken away), so the injected unreadable answer lands on the OAuth-start GET and the log asserts method GET. Bring the provider back for the recovery step. Addresses the spec-provenance finding on the journey.
|
Passed · 1/1 tests · 2/2 assertions · 0 images Commit |
|
Second test evidence section for head 0aa304c (the sticky comment holds the boundary spec run for the same head; the publisher keeps one run per sticky comment). Screenshots stay local — no blob token used by request. Supersedes the earlier e2e sections. The CI Product journeys run is withheld for this PR because it touches Test evidence — the connections page explains an OAuth-start answer the browser could not read, then connects once it can — ✅ passedSHA 0aa304c · engine v1 ✅ 0/3 screenshots passed · 3 assertions · 3 expectations passed · 0 failed · 0 pending
[world] den(local) · orgConnection("Synthetic calendar provider") · web(signed in) ℹ️ ASSERTION — 1. A readable handshake failure shows den-api's diagnosticWith the provider unreachable, the preflight passed (204) and den-api's own HTTP 502 was forwarded unchanged; the connection row shows the structured message with a diagnostic reference, not the readability or browser text.
ℹ️ ASSERTION — 2. An unreadable OAuth-start answer is explained in plain wordsThe proxy answered the OAuth-start GET (not its preflight) with an injected HTTP 502 the browser could not read; the connection row shows the readability message instead of "Failed to fetch" or a den-api diagnostic.
ℹ️ ASSERTION — 3. A readable OAuth-start answer starts the provider sign-inWith the fault cleared and the provider back, the proxied OAuth-start GET returned HTTP 200, the synthetic provider received an authorization request, and neither failure message remained.
⚪ UNVALIDATED — 4. the connections page explains an OAuth-start answer the browser could not read, then connects once it can artifact 1
⚪ UNVALIDATED — 5. the connections page explains an OAuth-start answer the browser could not read, then connects once it can artifact 3
⚪ UNVALIDATED — 6. the connections page explains an OAuth-start answer the browser could not read, then connects once it can artifact 5
Test run created 2026-09-09T05:31:45.799Z · Source: |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (0aa304c6b946fe2c28a714765627e68918063ad4). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
…a real tab (#4678) When a member clicks Connect on an external MCP connection, den-api's OAuth-start route answered handshake failures with HTTP 502. The API sits behind an edge that replaces origin 502/504 responses with its own CORS-less error page, so the browser on the web origin could never read den-api's diagnostic: the member saw a generic "could not read the answer, try again" even when the provider's authorization server had refused OpenWork's redirect URI and retrying could not help. den-api - Classify a dynamic-client-registration 400 that rejects the redirect URI (provider error invalid_redirect_uri, or invalid_request / invalid_client_metadata naming the redirect URI) as MCP_OAUTH_REDIRECT_URI_NOT_ALLOWED: not retryable, provider_admin owns it, plain-language message and operator action. - Answer connect/start handshake failures with 424 instead of 502 so the diagnostic reaches the browser; include callbackUrl for the new code so the UI can show what the provider must allowlist. SDK regenerated. den-web - Connect opens a same-window tab at /connect/oauth (rendered with the shared OpenWork status shell) instead of an about:blank popup window filled by document.write. - The failure screen explains what happened in the member's words, with advice driven by retryable/actionOwner (never "try again" when retrying cannot help), copyable redirect URI and reference, and technical details on demand. The unreadable-response wording from #4666 is kept. Proof - evals/specs/mcp-oauth-start-browser-readable-errors.test.ts: 424 with readable CORS, the new diagnostic for both provider error shapes, callbackUrl, and the untrusted-origin negative. - evals/specs/mcp-oauth-start-unreadable-response.e2e.test.ts: the tab is a same-window /connect/oauth page (no about:blank target) for a readable 424, an unreadable answer, and a provider refusing the redirect URI (named provider, redirect URI, reference, no retry advice), then the same button starts provider sign-in. - scripts/mock-oauth-mcp-server.mjs: MOCK_REJECT_DCR_REDIRECT_URIS reproduces the provider refusal deterministically.
Why
A member clicks Connect on a Den web connection and the browser's
GET /v1/mcp-connections/:id/connect/startfails before the page can read the response: a cross-origin error answer without usable CORS headers (or no answer at all). Today the connection row and the sign-in popup only echo the browser's ownFailed to fetch, with no Technical details, so members and support cannot tell a blocked response from a provider problem.This PR makes that failure readable in the UI and adds boundary proof of den-api's own error-path CORS behaviour. It does not fix or explain why a given deployment's OAuth-start request returns an error; that stays an operational investigation (edge vs. den-api logs).
What changed
den-webuseStartMcpConnectionOAuth: a pre-response failure (fetchTypeError) is wrapped inMcpOAuthStartErrorwithhttpStatus: "unavailable",errorCode: response_unreadable, the browser's own error text in the payload, and a plain message. Den's timeout, cancel and re-authentication errors are untouched. The popup's HTTP status row renders "Unavailable — the browser could not read the response" instead of a fake number.evals/specs/mcp-oauth-start-browser-readable-errors.test.ts: den-api answers OAuth-start preflights,200, downstream-failure502(oauth_handshake_failed+ diagnostic reference) and401with exactly oneAccess-Control-Allow-Originfor the trusted web origin andAccess-Control-Allow-Credentials: true; an untrusted origin gets no allow-origin on preflight or on the502. (No den-api code change was needed: in the default, non-edge CORS mode the structured502already carries the headers.)evals/specs/mcp-oauth-start-unreadable-response.e2e.test.ts+ worldevals/worlds/mcp-oauth-start-unreadable.ts: a fault proxy is fixed in front of den-api before Den boots (DEN_API_PUBLIC_URL→ proxy). Three steps on the Your Connections page in headless Chrome: (1) provider taken away → den-api's own502is forwarded with CORS headers and the row showsCould not connect "…": … Reference: …(preflight204+ GET502observed at the proxy); (2) the proxy injects an answer the browser may not read on the OAuth-start GET (preflight already cached; the log asserts exactly one faultedGET 502) → the row shows the readability message, notFailed to fetchnor a diagnostic reference; (3) fault cleared and provider back → the same button proxiesGET 200and the provider receives/authorize. Registered injourney-catalog.mjsasplacement: 'local'and declaredneeds.placement: "local".Proof (local lane; Daytona not used by request)
Base
4d7727740, head0aa304c6b(both specs re-run cold on this head). CI note: the Product journeys workflow is withheld for PRs touchingevals/scripts/, so the journey evidence is the published local run.Verdict: Passed for the two specs above. Pre-existing, unrelated red on base and head:
ee/apps/den-web tests/cloud-super-admins-role-hierarchy.test.ts(1 fail, fails identically on4d7727740) andpnpm evals:typecheck(errors inapps/server,packages/email, older specs; none in files touched here).Notes for reviewers
useStartMcpConnectionOAuth(that PR addsattemptId); the changes are independent and whichever lands second needs a one-line rebase.Access-Control-Allow-Origin: *, which a credentialed request may not read — same user-visible outcome as a missing header. The fault lands on the GET (the preflight is cached by the earlier readable failure), as the proxy log assertion shows.