Repository navigation
fix: reject invalid ListTasks status filters with RequestMalformedError - #631
Conversation
🧪 Code Coverage
Generated by coverage-comment.yml |
ef43956 to
83d1341
Compare
|
Hi @JakubWorek, thanks for the heads-up — the branch was based on a chain that included the #625 commits. I've rebased it onto the current |
JakubWorek
left a comment
There was a problem hiding this comment.
Overall changes are correct, however I'd move them to request handler. Currently grpc listTasks method is not covered by them and this violates Functional Equivalence Requirement.
Move the invalid status rejection from the JSON-RPC and REST transport handlers into DefaultRequestHandler.listTasks so gRPC — which decodes status as a raw enum number without going through taskStateFromJSON — is covered too, satisfying the spec §5.1 Functional Equivalence Requirement across all transports. The handler rejects any state outside VALID_TASK_STATE_LIST (new shared constant covering every named TaskState) with RequestMalformedError; unrecognized wire values that protobufjs maps to the synthetic UNRECOGNIZED (-1) sentinel now surface as malformed instead of silently matching nothing. Transports return to plain parse-and-forward, and their specs assert the pass-through plus the error mapping of a handler-raised RequestMalformedError (-32602 / HTTP 400).
ea14f5d to
e48a968
Compare
|
Thanks for catching this @JakubWorek — you're right, validating at the REST layer left A side effect worth calling out: an unknown status previously deserialized to protobufjs' synthetic The transport handlers are back to plain parse-and-forward; their specs now assert pass-through of the parsed value plus correct mapping of a handler-raised |
🤖 I have created a release *beep* *boop* --- ## [1.2.0](v1.1.0...v1.2.0) (2026-09-18) ### Features * **server:** Introduce SettleByTaskId method ([#692](#692)) ([e856bda](e856bda)) ### Bug Fixes * accept GetExtendedAgentCard JSON-RPC calls with omitted params ([#687](#687)) ([047d970](047d970)) * avoid mutating caller message configuration ([#725](#725)) ([e3a6428](e3a6428)) * **client:** cache the extended Agent Card only after signature verification ([#711](#711)) ([55b601c](55b601c)) * guard terminal state transitions and make cancelTask atomic ([#636](#636)) ([7b87c94](7b87c94)) * preserve call context for JSON-RPC tenant requests ([#708](#708)) ([ae20aca](ae20aca)) * preserve HeadersInit in authenticating fetch ([#721](#721)) ([f8c33fa](f8c33fa)) * preserve historyLength=0 and reject invalid REST listTasks pageSize ([#685](#685)) ([32c1865](32c1865)) * reject empty task IDs with RequestMalformedError in getTask/cancelTask ([#629](#629)) ([71aae97](71aae97)) * reject invalid ListTasks status filters with RequestMalformedError ([#631](#631)) ([a881fae](a881fae)) * reject missing required extensions before mutating task history ([#690](#690)) ([3b4ef3f](3b4ef3f)) * reject whitespace-only taskId on sendMessage ([#689](#689)) ([85227a0](85227a0)) * return 404/-32001 for missing push notification configs ([#630](#630)) ([34f06e3](34f06e3)) * scope ExecutionEventBusManager by tenant and owner to match TaskStore ([#707](#707)) ([69d8899](69d8899)) * stamp the resolved taskId onto sendMessage push configs ([#688](#688)) ([cfb19a8](cfb19a8)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: Bartek Gralewicz <[email protected]>
What changed
1. Reject invalid
statusfilters onListTasksinstead of silently converting them toUNRECOGNIZEDProblem: The generated
taskStateFromJSON(froma2a.proto) maps any unknown status string or out-of-range number toUNRECOGNIZED(-1). The REST transport used it directly, soGET /tasks?status=INVALID_VALUEsilently applied anUNRECOGNIZEDfilter that matches nothing and returned an empty list — the client believed the filter worked. Python'sParseDictrejects invalid values; JS diverged. (The pb file is generated viabuf generatefrom the upstream A2A proto, so the fix lives in the transport parsing, not in the generated file.)Fix (src/server/transports/rest/rest_transport_handler.ts):
listTasksnow throwsRequestMalformedError('Invalid status filter')whentaskStateFromJSONyieldsUNRECOGNIZED, returning 400INVALID_ARGUMENTinstead of silently filtering.Fix (src/server/transports/jsonrpc/jsonrpc_transport_handler.ts):
ListTaskscase validates the parsedListTasksRequest.statusand rejectsUNRECOGNIZEDwithRequestMalformedError(-32602) before dispatching.Testing
npm test— 68 test files, 1510 tests passed.npx tsc --noEmit(no errors insrc/) andnpx tsc --noEmit -p tsconfig.test.jsonpass.listTaskswithstatus='bogus-status'andstatus='99'reject withInvalid status filter; a validTASK_STATE_COMPLETEDstill passes through; JSON-RPCListTaskswithstatus='bogus-status'returnsINVALID_PARAMS(-32602) and does not reach the handler.Behavior change: an invalid
statusonListTasksnow returns 400 (REST) /-32602(JSON-RPC) instead of 200 with an empty result set. Existing testGET /tasks > should treat unrecognized status values as UNRECOGNIZED (-1)was updated to assert the new 400 contract.