Commit 56c1960
fix(rest): map invalid history length to InvalidParamsError (#715)
## Description
Fixes REST `getTask` error handling when `historyLength` is invalid.
Previously, invalid `historyLength` values could throw
`IllegalArgumentException`
and be returned as an internal error (500). This change maps that case
to
`InvalidParamsError`, returning the correct client error semantics
(422).
## Changes
- Update `RestHandler#getTask(...)` to catch `IllegalArgumentException`
and return `InvalidParamsError`
- Add regression test:
- `RestHandlerTest#testGetTaskNegativeHistoryLengthReturns422`
## Validation
- Ran targeted REST handler tests and verified they pass
Fixes #714
---------
Co-authored-by: Emmanuel Hugonnet <ehsavoie@users.noreply.github.com>1 parent a667e90 commit 56c1960
2 files changed
Lines changed: 17 additions & 1 deletion
File tree
- transport/rest/src
- main/java/io/a2a/transport/rest/handler
- test/java/io/a2a/transport/rest/handler
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
418 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
419 | 424 | | |
420 | 425 | | |
421 | 426 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
| |||
0 commit comments