Commit cd61762
oliver
fix: return a self-describing 404 for an unknown SSE session
handle_post_message's session-lookup failure returned a bare "Could
not find session" 404, indistinguishable from any other cause and
naming neither the reason nor the remedy. This is the more common
sibling of the case fixed in 8058392 (self-describing error for a
request before initialization): that fix answers through the
ServerSession's responder once a session object exists, but a
restarted process has no session object at all for an unknown
session_id -- the rejection happens in handle_post_message itself,
one layer below where a JSON-RPC error could be shaped.
Every redeploy invalidates every previously-connected client's
session_id at once, so this 404 is what most stranded clients
actually hit, and it reads as a service outage rather than "restart
your MCP client."
Both 404 branches (unknown session_id, and the credential-mismatch
branch that deliberately mimics "session doesn't exist" so it can't
be used to probe for valid session IDs under another user) now share
one message via a single Response built once, so they can't drift
apart and leak which case occurred.
Updated test_sse_security_post_valid_content_type, which asserted the
old exact bare string -- it's testing content-type handling reaches
the 404 branch at all, not the message's wording, so relaxed to a
substring check.1 parent f7c8353 commit cd61762
3 files changed
Lines changed: 35 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
240 | 253 | | |
241 | 254 | | |
242 | 255 | | |
243 | | - | |
244 | | - | |
| 256 | + | |
245 | 257 | | |
246 | 258 | | |
247 | 259 | | |
248 | 260 | | |
249 | 261 | | |
250 | 262 | | |
251 | 263 | | |
252 | | - | |
253 | | - | |
| 264 | + | |
254 | 265 | | |
255 | 266 | | |
256 | 267 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | | - | |
| 313 | + | |
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
179 | 198 | | |
180 | 199 | | |
181 | 200 | | |
| |||
0 commit comments