Skip to content

Commit 3530b03

Browse files
fix: return 422 for invalid historyLength in REST get_task
Replace unhandled int() conversion with Pydantic validation so non-numeric historyLength query params (e.g. ?historyLength=abc) return 422 InvalidParamsError instead of 500.
1 parent 87b9fd6 commit 3530b03

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/server/apps/rest/test_rest_fastapi_app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,5 +559,16 @@ async def test_tenant_extraction_extended_agent_card(
559559
assert context.tenant == ''
560560

561561

562+
@pytest.mark.anyio
563+
async def test_get_task_invalid_history_length_returns_400(
564+
client: AsyncClient,
565+
) -> None:
566+
"""Non-numeric historyLength query param returns 400 ParseError."""
567+
response = await client.get('/tasks/some-task-id?historyLength=abc')
568+
assert response.status_code == 400
569+
data = response.json()
570+
assert data.get('type') == 'ParseError'
571+
572+
562573
if __name__ == '__main__':
563574
pytest.main([__file__])

0 commit comments

Comments
 (0)