refactor: implement strict Content-Type validation for JSON-RPC and REST requests, and update event loop termination logic for interrupted states, update ci pipelines for itk#519
Conversation
…EST requests, and update event loop termination logic for interrupted states, update ci pipelines for itk
🧪 Code Coverage
Generated by coverage-comment.yml |
There was a problem hiding this comment.
Code Review
This pull request introduces support for interrupted task states (INPUT_REQUIRED and AUTH_REQUIRED) by keeping the execution event bus alive when these states are encountered, allowing clients to resubscribe or send follow-up messages. It also adds content-type validation guards for both JSON-RPC and REST handlers to reject unsupported content types with a ContentTypeNotSupportedError (HTTP 400). Additionally, the JSON-RPC handler is updated to peek at the first event of a stream before flushing SSE headers, ensuring early failures are returned as standard JSON-RPC error responses. Tests have been updated to reflect these changes. I have no feedback to provide as there are no review comments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Description
This pull request introduces several important improvements to request handling, event streaming, and content type validation in the server codebase. The main focus is on correctly handling interrupted (non-terminal) task states, enforcing strict content type requirements for JSON-RPC and REST endpoints, and improving the robustness of server-sent event (SSE) streaming error handling. These changes enhance protocol compliance (especially with the A2A specification), prevent subtle bugs, and improve client-facing error reporting.
Task execution and event bus management:
INTERRUPTED_STATE_LISTto distinguish non-terminal task states (such asINPUT_REQUIREDandAUTH_REQUIRED) that pause execution but keep the task and event bus alive for follow-up actions. The event bus is now only closed for truly terminal states, allowing clients to resubscribe or continue tasks as specified in the A2A protocol (§3.4.3).trackLatestTaskStateutility to reliably track the most recent task state on the event bus, ensuring correct bus lifecycle management even when consumer processing lags behind event publishing.Content type enforcement for API endpoints:
application/jsonfor JSON-RPC endpoints and eitherapplication/jsonorapplication/a2a+jsonfor REST endpoints. Requests with unsupported content types now return aContentTypeNotSupportedErrormapped to HTTP 400, improving protocol compliance and error clarity.Streaming and error handling improvements:
Workflow trigger refinement:
epic/**rather than justepic, ensuring workflows run for all relevant feature branches.Part of changes from #517