-
Notifications
You must be signed in to change notification settings - Fork 1.9k
test(e2e): hosting-entry-http arm-posture fix; widen method-405 probe set #2334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fweinberger/on-m12
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,9 +32,11 @@ function echoFactory(_ctx?: McpRequestContext): McpServer { | |
|
|
||
| verifies('typescript:hosting:entry:method-405', async ({ transport }: TestArgs) => { | ||
| const client = new Client({ name: 'method-405-client', version: '1.0.0' }); | ||
| await using wired = await wire(transport, echoFactory, client, { entry: { legacy: 'stateless' } }); | ||
| // No `entry` override: the arm posture (`stateless` on entryStateless, | ||
| // `reject` on entryModern) is the configuration under test. | ||
| await using wired = await wire(transport, echoFactory, client); | ||
|
Comment on lines
33
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 The same arm-posture override this PR removes still survives in the sibling file at Extended reasoning...What the bug is. This PR removes the The code path. Step-by-step proof. (1) The matrix schedules Why nothing prevents it. The override is silent: nothing warns that a per-test Why line 39 is excluded. The other surviving site, Impact and fix. No test failure — purely a coverage-fidelity gap and an inconsistency with the principle this PR states ('the arm posture is the configuration under test'). Fix is the same one-line change applied to the three cells in this PR: drop the fourth argument at |
||
|
|
||
| for (const method of ['PUT', 'PATCH']) { | ||
| for (const method of ['GET', 'DELETE', 'PUT', 'PATCH']) { | ||
| const response = await wired.fetch!(wired.url!, { method }); | ||
| expect(response.status).toBe(405); | ||
| const body = (await response.json()) as { jsonrpc: string; error: { code: number; message: string } }; | ||
|
|
@@ -46,7 +48,7 @@ verifies('typescript:hosting:entry:method-405', async ({ transport }: TestArgs) | |
|
|
||
| verifies('typescript:hosting:entry:parse-error-400', async ({ transport }: TestArgs) => { | ||
| const client = new Client({ name: 'parse-error-client', version: '1.0.0' }); | ||
| await using wired = await wire(transport, echoFactory, client, { entry: { legacy: 'stateless' } }); | ||
| await using wired = await wire(transport, echoFactory, client); | ||
|
|
||
| const response = await wired.fetch!(wired.url!, { | ||
| method: 'POST', | ||
|
|
@@ -138,7 +140,7 @@ verifies('typescript:hosting:entry:legacy-protocol-version-default', async ({ tr | |
|
|
||
| verifies('typescript:hosting:entry:no-session-id', async ({ transport }: TestArgs) => { | ||
| const client = new Client({ name: 'no-session-id-client', version: '1.0.0' }); | ||
| await using wired = await wire(transport, echoFactory, client, { entry: { legacy: 'stateless' } }); | ||
| await using wired = await wire(transport, echoFactory, client); | ||
|
|
||
| // A typed round trip through the wired client (so both the connect-time | ||
| // negotiation and a follow-up request are recorded), then assert no | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟣 Pre-existing SDK gap, unrelated to this test-only PR: both 405 paths reachable through
createMcpHandler(the legacy stateless fallback's non-POST rejection and the modern-only strictmodern-only-method-not-allowedrejection) return 405 without theAllowheader that RFC 9110 §15.5.6 requires, even though the per-sessionWebStandardStreamableHTTPServerTransportalready emitsAllow: GET, POST, DELETEon its 405. The eventual fix is to emitAllow: POSTfrom the two entry-side 405 sites — at which point the requirement note reworded here ("The entry does not emit an Allow header…") will need updating.Extended reasoning...
What the gap is. RFC 9110 §15.5.6 says an origin server generating a 405 (Method Not Allowed) response MUST generate an
Allowheader field listing the methods the target resource supports. Both 405 paths reachable throughcreateMcpHandleromit it:packages/server/src/server/createMcpHandler.ts:309-311returnsjsonRpcErrorResponse(405, -32000, 'Method not allowed.'), andjsonRpcErrorResponse(lines 261-270) builds theResponse.jsonwith only a status — no headers.modern-only-method-not-allowedrejection atpackages/core/src/shared/inboundClassification.ts:856-858is rendered throughrejectionResponse()(createMcpHandler.ts:272-274), which delegates to the same header-lessjsonRpcErrorResponse.Why it's an inconsistency, not a design choice. The per-session
WebStandardStreamableHTTPServerTransportalready complies: itshandleUnsupportedRequestemitsAllow: 'GET, POST, DELETE'on its 405 (packages/server/src/server/streamableHttp.ts:625). So the SDK follows the RFC on the sibling transport but not on the two entry-side sites — a parity gap rather than a deliberate omission.How this PR interacts with it. The PR is test-only and does not introduce the gap — the sentence "The entry does not emit an Allow header (the per-session server transport does)" already appears verbatim in the line being replaced. But the PR widens the
method-405probe loop from['PUT','PATCH']to['GET','DELETE','PUT','PATCH']and rewords the requirement note attest/e2e/requirements.ts:2405-2411, so it now documents and observes (without asserting) the non-compliant 405 shape for four methods on both entry arms.Step-by-step proof. (1) The widened loop sends
GETto theentryStatelessarm's URL viawired.fetch. (2)createMcpHandlerroutes the body-less non-POST request tolegacyStatelessFallback, which hits therequest.method !== 'POST'guard atcreateMcpHandler.ts:309and returnsjsonRpcErrorResponse(405, -32000, 'Method not allowed.'). (3)jsonRpcErrorResponseconstructs the response with{ status: 405 }only, soresponse.headers.get('allow')isnull— violating the RFC 9110 MUST. (4) On theentryModernarm the sameGETis classified asmodern-only-method-not-allowed(inboundClassification.ts:856-858) and rendered byrejectionResponse()→ the same header-less builder, soAllowis again absent. (5) By contrast, sendingPUTto a hand-hosted per-session transport reacheshandleUnsupportedRequestatstreamableHttp.ts:611-625and getsAllow: GET, POST, DELETEback.Impact and fix. Impact is HTTP-compliance/interop polish: well-behaved generic HTTP clients and proxies use
Allowto discover supported methods after a 405. The fix is a one-liner per site — emitAllow: 'POST'(the only method either entry leg serves) from the two entry-side 405 paths. That change belongs in an SDK PR, not this test-only one; when it lands, the requirement note text touched here (and the note that the test deliberately doesn't pin the header) should be updated to assertAllow: POST. Filing aspre_existingso it's tracked without blocking this PR.