fix(api-server): validate previous_response_id type and length (salvage of #2961 by @aydnOktay) - #62758
fix(api-server): validate previous_response_id type and length (salvage of #2961 by @aydnOktay)#62758Bartok9 wants to merge 2 commits into
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for carrying the original hardening forward. The premise is live on current main: both handlers pass a client-provided previous_response_id into ResponseStore.get without validation (gateway/platforms/api_server.py:3285-3286, gateway/platforms/api_server.py:4222-4223), and the PR validates both paths before that lookup.
Problems
- The added tests cover only POST
/v1/responses. The test app registers that route attests/gateway/test_api_server.py:616, but not POST/v1/runs; production registers/v1/runsatgateway/platforms/api_server.py:4805. The new_handle_runsvalidation therefore has no regression coverage.
Suggested changes
- Add invalid-type and overlength requests for POST
/v1/runs, by extending the test app helper or invoking_handle_runsdirectly, and assert the same 400 contract.
This is an automated hermes-sweeper review.
| @@ -4119,3 +4120,38 @@ class FakeRunner: | |||
| assert adapter._session_model_override_for("chan-1") == {"model": "user/model"} | |||
| assert adapter._session_model_override_for("chan-2") is None | |||
| assert adapter._session_model_override_for(None) is None | |||
|
|
|||
|
|
|||
| class TestPreviousResponseIdHardening: | |||
There was a problem hiding this comment.
These tests exercise only /v1/responses, but this PR also changes _handle_runs. Please add equivalent 400 regression coverage for POST /v1/runs; the current _create_app helper registers /v1/responses but not that production route.
|
Review addressed:
`pytest tests/gateway/test_api_server.py::TestPreviousResponseIdHardening` → 4 passed. |
|
Rebased onto current Review (jquery/teknium keep_open) was already addressed on this salvage:
Local: Ready for re-review when CI is green. Not merging from author side. |
e46abeb to
efa0ca7
Compare
…ge of NousResearch#2961 by @aydnOktay) Rebuilt on latest main (Bartok9 hygiene 2026-08-01). Original: NousResearch#62758
|
Rebuilt onto latest — Bartok9 public PR hygiene 2026-08-01 |
efa0ca7 to
c0024ca
Compare
…tok9 Per-PR attribution so check-attribution passes on this branch (Teknium).
Summary
Salvages #2961 by @aydnOktay onto current main.
What the original PR fixed
previous_response_idaccepted non-strings and unbounded lengths before store lookup.Why it needed salvage
Still open; endpoint code has grown (multiple handlers). Port validation to current parse paths with tests.
Changes from original
previous_response_idTesting
Full credit to @aydnOktay.