Commit 6ee870b
fix: return a self-describing 404 for an unknown streamable-http session (#1)
* fix: return a self-describing 404 for an unknown streamable-http session
StreamableHTTPSessionManager answered a request for a missing or
credential-mismatched session with a bare "Session not found" -- the
same misleading-error problem #19/#26 already fixed for
SseServerTransport's equivalent case (a redeploy or expiry invalidating
every connected client's session_id at once), just not ported to this
transport.
Both call sites now share one message via _session_not_found_response(),
built once so the "unknown session" and "credential mismatch" cases
(which must answer identically -- see the comment) can't drift apart.
Verified: full suite 1140 passed / 0 regressions (95 skipped, 1 xfailed,
2 pre-existing collection errors for the unrelated optional `websockets`
extra, not installed in this environment) plus ruff and pyright clean.
* fix: address review -- comment direction, unvalidated input note, expire coverage
- _session_not_found_response's comment said "callers below" / "check
above" -- true when this sat inline in sse.py, backwards once hoisted
to a module-level function above both call sites. Converted to a
docstring, direction fixed.
- session_id here is the raw, client-supplied mcp-session-id header,
never validated against SESSION_ID_PATTERN (only IDs the server mints
are) -- unlike sse.py's session_id.hex, which is already
UUID-validated. Safe (JSON-escaped, application/json, truncated to
64 chars matching the file's existing convention) but the docstring
now says so, rather than leaving it to be re-derived later.
- Test now asserts "expire" is covered, not just "restart" -- the one
genuinely new clause this message adds over the sse-side wording
(this transport has a session_idle_timeout; sse doesn't), which was
the one claim the prior substring checks didn't actually verify.
---------
Co-authored-by: oliver <oliver.sampson@gitterdan.ai>1 parent cd61762 commit 6ee870b
2 files changed
Lines changed: 48 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
35 | 70 | | |
36 | 71 | | |
37 | 72 | | |
| |||
264 | 299 | | |
265 | 300 | | |
266 | 301 | | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
| 302 | + | |
275 | 303 | | |
276 | 304 | | |
277 | 305 | | |
| |||
354 | 382 | | |
355 | 383 | | |
356 | 384 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
| 385 | + | |
363 | 386 | | |
364 | 387 | | |
365 | 388 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
399 | 401 | | |
400 | 402 | | |
401 | 403 | | |
| |||
439 | 441 | | |
440 | 442 | | |
441 | 443 | | |
442 | | - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
443 | 452 | | |
444 | 453 | | |
445 | 454 | | |
| |||
0 commit comments