Repository navigation
Commit 5a1a004
authored
fix(server): stop printing a traceback to stderr for malformed JSON-RPC bodies (a2aproject#1301)
# Description
When a JSON-RPC request body is not valid JSON,
`JsonRpcDispatcher.handle_requests` called `traceback.print_exc()`
before returning the `-32700` error. Every malformed client request
therefore wrote a full stack trace to the server's stderr, outside the
application's logging configuration (no level, no handler, no way to
silence it). The same error is already logged at `WARNING` through the
module logger by `_generate_error_response`, like every other request
error, so the print only duplicated it.
- Remove the `traceback.print_exc()` call and the now-unused import.
- Regression test: a malformed body still returns `-32700`, nothing is
written to stderr, and the module logger records a `WARNING`. It fails
on main.
Checks: `scripts/lint.sh` clean, `uv run pytest` 2181 passed (plus
`tests/integration/cross_version` 5 passed), coverage 93%.
- [x] Follow the [`CONTRIBUTING`
Guide](https://github.com/a2aproject/a2a-python/blob/main/CONTRIBUTING.md).
- [x] Make your Pull Request title in the
<https://www.conventionalcommits.org/> specification.
- [x] Ensure the tests and linter pass
- [x] Appropriate docs were updated (if necessary)1 parent dac7d9d commit 5a1a004
2 files changed
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
327 | 326 | | |
328 | 327 | | |
329 | 328 | | |
330 | | - | |
331 | 329 | | |
332 | 330 | | |
333 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
160 | 177 | | |
161 | 178 | | |
162 | 179 | | |
| |||
0 commit comments