Repository navigation
Commit f451ed7
fix(server): reject out-of-range ListTasks cursor timestamps (a2aproject#1451)
# Description
Fixes a2aproject#1450.
`ListTasks` with `DatabaseTaskStore` returns HTTP 500 when a
structurally valid page token contains an out-of-range timestamp.
Protobuf 7.36.2 raises `ValueError` from `Timestamp.FromNanoseconds()`,
while `_after_cursor` only converts `OverflowError` into
`InvalidParamsError`.
Handle both exceptions so these tokens use the existing HTTP 400 /
`INVALID_ARGUMENT` / `Invalid page token` response. The production
change is one exception clause. Add four regression cases covering
values immediately outside the timestamp range and very large
positive/negative integers.
## Verification
Tested source `main` at `2cc1dd5`, Python 3.12.16, Windows, Protobuf
7.36.2, and SQLite/aiosqlite. Final checks used the exact dependencies
exported from `uv.lock` with hash verification.
- Before the fix, all four new SQLite cases failed with `ValueError`;
after the fix they pass. PostgreSQL/MySQL variants skip because their
DSNs are unset.
- Exercised real Starlette REST routes, `DefaultRequestHandlerV2`, and
an in-memory SQLite `DatabaseTaskStore` via `httpx.ASGITransport`,
without mocking the conversion or store: three invalid timestamps
changed from HTTP 500 to HTTP 400; `ts=null` and `ts=0` remained HTTP
200. No provider requests.
- `scripts/lint.sh`: passed Ruff check/format and ty. ty reports three
existing unused-ignore warnings in untouched client files; no type
errors.
- The suite with the two Windows-incompatible integration modules below
excluded: **2,556 passed, 215 skipped, 4 xfailed, 1 xpassed**.
- The same suite with `--cov=src --cov-report=term-missing
--cov-fail-under=88`: **93.57%** coverage, same test counts.
- `git diff --check`: passed.
The passing suite command (with UTF-8 enabled for sample CLI
subprocesses):
```sh
PYTHONUTF8=1 uv run pytest --timeout=45 -q \
--ignore=tests/integration/cross_version/client_server/test_client_server.py \
--ignore=tests/integration/push_notifications/test_default_push_notification_support.py
```
### Full-suite limitations
I also ran the unfiltered suite; it was **not green on this Windows
host**. Its initial result was 2,553 passed, 215 skipped, 4 xfailed, 1
xpassed, 3 failed, and 8 errors. The three sample CLI failures were GBK
console-encoding errors and passed with `PYTHONUTF8=1`.
The two excluded modules fail on the unchanged production source too
(verified by restoring the original exception clause and rerunning
them): the cross-version harness uses POSIX `os.killpg` and `:`-joined
`PYTHONPATH` and has short process startup/client timeouts; the
push-notification harness cannot pickle a locally created FastAPI
application under Windows spawn (`FastAPI.setup.<locals>.openapi`). I
left these unrelated harnesses unchanged. Linux, PostgreSQL, and MySQL
runs have not been performed locally.
## Checklist
- [x] Followed `CONTRIBUTING.md` and read the repository's AI workflow
documents.
- [x] Conventional Commit title and focused bug fix with regression
coverage.
- [x] Ran the lint script, unfiltered tests, and the passing
suite/coverage commands described above.
- [x] No documentation update needed: no public API or schema change.
AI disclosure: Codex investigated the code, reproduced the issue,
prepared and reviewed this patch, and ran the checks under the account
holder's instruction. Independent human review or reproduction is not
claimed.
Co-authored-by: Mateusz Iwaniuk <45974414+Iwaniukooo11@users.noreply.github.com>1 parent 14e799c commit f451ed7
2 files changed
Lines changed: 29 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
348 | | - | |
| 348 | + | |
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
1170 | 1174 | | |
1171 | 1175 | | |
1172 | 1176 | | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
1173 | 1200 | | |
0 commit comments