Commit b690b15
committed
fix(runtime): distinguish request parse errors from handler JSON errors
The broad try/except around _handle_invocation caught json.JSONDecodeError
from both request.json() (inbound payload) and the user's handler logic,
reporting both as "Invalid JSON in request" with HTTP 400. This misled
engineers into debugging caller payloads when the root cause was downstream
application/model-output parsing.
Narrow the JSONDecodeError and UnicodeDecodeError catches to only cover
request body parsing. Handler-raised exceptions now fall through to the
generic Exception handler (HTTP 500) with an accurate error message.
Constraint: Runtime contract returns 4xx for request-level errors only
Rejected: Catch handler JSONDecodeError separately with 422 | no precedent in runtime contract
Confidence: high
Scope-risk: narrow
Not-tested: Streaming handlers that raise JSONDecodeError mid-stream1 parent eddc27c commit b690b15
1 file changed
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
540 | 550 | | |
541 | 551 | | |
542 | 552 | | |
| |||
581 | 591 | | |
582 | 592 | | |
583 | 593 | | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | 594 | | |
594 | 595 | | |
595 | 596 | | |
| |||
0 commit comments