fix: never exempt a form-encoded request (#2319 round 20)
The exemption was URL-only, so an authorization server configured at the MCP endpoint's own URL — `oauthTokenUrl` takes any absolute URL — made the transport-internal refresh take the exempt branch and run with no signal, no body buffering and no deadline. That is the one request this change exists to bound. `isExempt` now receives the request's headers as well as its URL, and `exemptMcpEndpoint` refuses to exempt anything sent as `application/x-www-form-urlencoded`, before any URL comparison. That is a discriminator rather than a heuristic: the token exchange, the refresh and revocation are all form-encoded per RFC 6749 §4.1.3 and RFC 7009 §2.1, and MCP is JSON-RPC over application/json and never is. Also records, on the no-deadline route test, what it does not catch: at a 400ms wait an unconditional timer restored at the production 30s budget would still leave the request pending and the test would pass. Catching that needs either a ~31s wait on every CI run or a route-level deadline knob existing only for the test, and a second source of truth for the deadline is the defect round 13 removed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YFnM6RqB4nXqNysgUYmjmq Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
42339ff4a4
commit
e71b8b9dfb
1 changed files with 142 additions and 31 deletions
|
|
@ -505,6 +505,15 @@ describe("server.ts supplemental coverage", () => {
|
|||
// a Streamable HTTP tool call that legitimately withholds its response
|
||||
// headers — reintroducing on the backend exactly what `exemptMcpEndpoint`
|
||||
// prevents on the client, and reporting it as an OAuth timeout besides.
|
||||
//
|
||||
// ⚠️ What it does NOT catch, stated so nobody reads more into it: the
|
||||
// wait below is 400ms, so an unconditional timer restored at the
|
||||
// production 30s budget would still leave the request pending here and
|
||||
// the test would pass (Copilot). Catching that needs either a ~31s wait
|
||||
// on every CI run or a route-level deadline knob existing only for the
|
||||
// test — and a second source of truth for the deadline is the defect
|
||||
// round 13 removed. Measured, this fails against an unconditional timer
|
||||
// at any budget shorter than the wait.
|
||||
const caller = new AbortController();
|
||||
const pending = fetch(`${h.baseUrl}/api/fetch`, {
|
||||
method: "POST",
|
||||
|
|
|
|||
Loading…
Reference in a new issue