Repository navigation
fix(den): explain redirect-URI refusals and open provider sign-in in a real tab - #4678
Conversation
…a real tab 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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Test evidence (PR lane, companion to the sticky journey report) —
|
…-errors # Conflicts: # evals/packages/labs/src/mock-mcp.ts
|
Passed · 1/1 tests · 2/2 assertions · 0 images Commit |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (f9379011c7fbe8e6a70166f53b83b6c3583a3a81). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
Why
Clicking Connect on an external MCP connection could end in a generic "OpenWork could not read the answer from its API… try again" screen inside an
about:blankpopup window, even though den-api had a precise diagnosis. Root cause chain:invalid_redirect_uri, orinvalid_requestnaming the redirect URI). den-api classified this generically (MCP_HTTP_400).connect/starthandshake failures with HTTP 502.What changed
den-api
MCP_OAUTH_REDIRECT_URI_NOT_ALLOWED(phaseAUTH_CLIENT_REGISTRATION, not retryable,provider_adminowns it) with a plain-language message and operator action;providerCodecarries the provider's error.connect/starthandshake failures return 424 instead of 502 so the diagnostic reaches the browser; the body includescallbackUrlfor the new code. Route schema updated; SDK regenerated.502sites inmcp-connections.ts(validation, requirements discovery, tool catalog) have the same edge exposure and are left for a follow-up.den-web
/connect/oauth(rendered with the sharedDenStatusScreenOpenWork shell) instead of anabout:blankpopup window filled bydocument.write.retryable/actionOwner(never "try again" when retrying cannot help). A provider refusing the redirect URI gets: "{provider} hasn't approved OpenWork yet", the redirect URI to allowlist and the reference (copyable), and technical details on demand. The unreadable-response wording from fix(den-web): explain OAuth-start answers the browser cannot read #4666 is kept.Test tooling
scripts/mock-oauth-mcp-server.mjs+mcpMock({ rejectDynamicRedirectUris })reproduce the provider refusal deterministically.Proof
Coverage decision: extend the two existing journeys (no new spec files).
pnpm evals:pr specs/mcp-oauth-start-browser-readable-errors.test.ts—placement: local (PR lane resolved by testkit)— Passed (1/1). Asserts 424 with exactly one readableAccess-Control-Allow-Origin,MCP_OAUTH_REDIRECT_URI_NOT_ALLOWEDfor both provider error shapes withcallbackUrl, the vanishing-provider failure keeping a different code and nocallbackUrl, no secrets in bodies, and no CORS allowance for untrusted origins.pnpm evals:e2e mcp-oauth-start-unreadable-response --local—placement: local (--local); the journey declares local placement because the fault proxy must sit in front of den-api before Den boots — Passed (1/1, 0 skipped). Asserts the sign-in tab is a same-window/connect/oauthpage (noabout:blanktarget) for a readable 424, an unreadable injected answer, and a provider refusing the redirect URI (named provider, redirect URI, reference, no retry advice and no readability message, zero provider authorize requests), then the same button starts provider sign-in once the provider accepts.test/external-mcp-diagnostics.test.ts89/89; den-web typecheck clean; den-web unit suite 228/229 — the one failure (cloud-super-admins-role-hierarchy) reproduces onorigin/devwith this branch's den-web changes stashed, so it is pre-existing;pnpm --filter @openwork/sdk generate:checkclean.Evidence report is published as the sticky test-evidence comment below.