Repository navigation
Surface delegated credential errors in vMCP - #7353
Conversation
Keep per-user credential failures distinct from backend failures so clients can tell when to authorize a provider without seeing transport or workflow context. Nothing produces these errors yet; this prepares the call path for the outgoing strategy that reads the delegated credential. tools/call renders an authorization requirement as an isError result naming the provider, and an unavailable credential as a fixed JSON-RPC internal error, on both Legacy and Modern and through the Legacy optimizer's call_tool. A denial still wins, then a URL elicitation answer, so a later connect link is never hidden by the plain message. Composite tools return these errors to the renderers instead of flattening them into workflow text, and forEach keeps the cause. Legacy resources/read and prompts/get send -32603 for an unavailable credential, matching Modern. Workflow steps do not retry these errors, and dispatch does not fall back to Legacy or re-probe when the probe or a corrective re-probe fails on a credential. An optional Modern list that fails on a credential still degrades, but its WARN names the credential failure. A backend whose credential fails during discovery is still left out of the tool list; the docs record that limit. Co-authored-by: Mecatl <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7353 +/- ##
==========================================
+ Coverage 82.59% 82.68% +0.08%
==========================================
Files 943 944 +1
Lines 96943 97034 +91
==========================================
+ Hits 80074 80232 +158
+ Misses 16864 16797 -67
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rdimitrov
left a comment
There was a problem hiding this comment.
Reviewed against Part C of #6407, #7188 and #7189.
The mapping matches the design. A missing connection or a rejected grant is a tool error that names the provider, never 401 or 403. A storage or transient failure is -32603 with a fixed message, and other tools keep working. The order (denial, then URL elicitation, then authorization required, then unavailable) leaves room for the connect link in #7188.
I checked the seams beyond the unit tests with a throwaway integration test. It ran a real vMCP server against two real streamable-HTTP backends. The second backend used an outgoing strategy that returns these errors on the call path. Results on 2025-11-25 and 2026-07-28:
- A direct call, a one-step composite and a forEach composite all return exactly
provider "github" requires upstream authorization(asisError) or-32603 upstream credential unavailable. - No backend URL, workload name, workflow text or strategy cause reaches the body. A plain strategy error, by contrast, still leaks all of these, so the producer must return these types.
- The other backend's tool works throughout, and the failing backend recovers once its strategy succeeds.
go test -race ./pkg/vmcp/... passes.
One gap, non-blocking: code mode. execute_tool_script calls VMCP.CallTool directly (pkg/vmcp/codemode/decorator.go:444) and hands the error to the script, so neither renderer runs on that path. The script sees the bare text and the outer call answers with an ordinary tool result. The text is safe, so nothing needs fixing here. But docs/error-handling.md doesn't list this path, and the URL elicitation from #7188 can't reach a client through it. Worth a line in the doc, or a note on #7188.
The CRD reference generator scans pkg/vmcp/auth/types, and the new DelegatedAuthRequiredError struct there adds an empty entry to the generated page. Co-authored-by: Mecatl <[email protected]>
A script's tool call goes to VMCP.CallTool directly, so neither tools/call renderer runs on it: the script gets the error text and the outer call answers with an ordinary tool result. Say so, and that a URL elicitation cannot reach the client through a script. Co-authored-by: Mecatl <[email protected]>
|
@rdimitrov thanks for the integration run. Added a paragraph on code mode to the limitations in docs/error-handling.md: script tool calls skip both renderers, the script gets the plain text, and a URL elicitation can't reach the client through a script. Also regenerated the CRD reference docs, since the new struct in Agreed on the plain strategy errors leaking. The producer has to return these types, and I'll make sure that PR does and tests for it. |
rdimitrov
left a comment
There was a problem hiding this comment.
Re-approving. The two commits since my review only touch docs. The code-mode paragraph in docs/error-handling.md covers the gap I raised, and the regenerated crd-api.md entry is expected. The branch merges cleanly with main, including #7354, and no files overlap.
Summary
The delegated credential read (Part of "Ownership-checked credential read for delegated tokens, keyed by user and routed provider") needs a call that fails on the user's credential to look different from a backend failure. Clients should see "connect provider X" or a fixed "credential unavailable", not transport text, workflow wrapping or a Legacy-fallback retry. Today every such failure goes through the generic backend error classification, so it would come back as "backend unavailable: ..." or "authentication failed ...". Nothing produces these errors yet; the strategy that does lands next, and this PR prepares the call path so it renders correctly from the start.
DelegatedAuthRequiredError(names the provider) andErrDelegatedCredentialUnavailableinpkg/vmcp/auth/types, plusvmcp.DelegatedCredentialFailure, which returns the delegated error unless the chain also carries a denial or a URL elicitation answer.dispatchdoes not fall back to Legacy or reclassify when the probe, the call, or a corrective re-probe fails on a credential.tools/callon Legacy and Modern, including the Legacy optimizer'scall_tool:isErrorresultprovider "X" requires upstream authorization-32603with the fixed messageupstream credential unavailableresources/readandprompts/getsend-32603for an unavailable credential, matching Modern (the SDK otherwise sends code 0).docs/error-handling.mddescribes the responses and the limit below;docs/arch/10-virtual-mcp-architecture.mdcovers the probe exception and the renderer order.Part of #6407
Type of change
Test plan
task test)task lint-fix)Ran
go test -raceover./pkg/vmcp/...,./pkg/auth/upstreamtoken/...and./pkg/authserver/...after rebasing on main. New tests cover each response through a real core and workflow engine and through both the Legacy and Modern handlers, the precedence chains through the client, the re-probe case, and the Legacy wire code for resources/prompts.Does this introduce a user-facing change?
Not for delegated credentials yet, since nothing produces these errors. One small change is visible now: a composite tool whose forEach iteration times out used to answer
Workflow execution failed: ...(logged at ERROR); it now answersWorkflow execution timeout exceeded(logged at WARN), the same as a tool step that times out, because forEach now keeps the iteration error as a cause.Special notes for reviewers
isErrortext, as composites did before. Only chains where the delegated error ranks highest are returned unflattened.categorizeErrortoday. The producer must keep that, otherwise a bare delegated error would fall into the unhealthy default.