test(e2e): expect SdkHttpError after a second 401 from onUnauthorized - #2936
Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012VRbFCp41otcScXE1YY3es
|
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
There was a problem hiding this comment.
Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.
Beyond the inline note, I checked whether this silently redefines the requirement: the JSDoc on AuthProvider.onUnauthorized() (packages/client/src/client/auth.ts:88-92) and the transport (packages/client/src/client/streamableHttp.ts:1099-1107) both already specify SdkHttpError (ClientHttpAuthentication, status 401) on the post-retry 401 and UnauthorizedError only without onUnauthorized, so the manifest wording now matches shipped behavior rather than diverging from it. Also ruled out: the second rejects.toMatchObject on the same settled promise is fine (vitest re-awaits it), and status being a prototype getter on SdkHttpError is matched by toMatchObject since subset matching walks the prototype chain; no other knownFailures or coverage target references the old body title.
Extended reasoning...
The change touches only the e2e conformance suite (test/e2e/requirements.ts and test/e2e/scenarios/client-auth.test.ts): it rewords one manifest entry, removes its knownFailures record, and flips the matching scenario body from a test.fails() assertion of UnauthorizedError to a passing assertion of SdkHttpError. No SDK source changes; the asserted behavior matches the current JSDoc on AuthProvider.onUnauthorized() and the streamableHttp transport's auth-retry path. It exercises auth error surfacing in tests but modifies no auth code. Deferring rather than approving because the repo CODEOWNERS assigns all paths to the SDK team and I could not run the suite in this sandbox (no node_modules), so the passing claim rests on static reading.
Requested by Felix Weinberger · Slack thread
Follows #2934, which corrected the
AuthProvider.onUnauthorized()docs.Before: the e2e manifest recorded a second 401 after the
onUnauthorizedretry as surfacing asUnauthorizedError, and listed the real behaviour as a known failure.After: the requirement says what the client does: a second 401 on the retry rejects with
SdkHttpError(ClientHttpAuthentication); withoutonUnauthorizedthe 401 surfaces asUnauthorizedError. The scenario expects that and the known-failure entry is gone.Motivation and Context
Keeps the e2e requirement registry consistent with the documented and implemented behaviour.
How Has This Been Tested?
client-authscenario: all four cells of the requirement pass; coverage gates pass; typecheck and lint clean.Breaking Changes
None. Test files only; no changeset.
Types of changes
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_012VRbFCp41otcScXE1YY3es
Generated by Claude Code