fix(a2a-server): add missing return after 501 in /tasks/metadata endpoint - #21730
fix(a2a-server): add missing return after 501 in /tasks/metadata endpoint#21730yashodipmore wants to merge 2 commits into
Conversation
…oint When using a non-InMemory task store (e.g., GCSTaskStore), the GET /tasks/metadata handler sends a 501 response but does not return, causing the code to fall through into the try block. This attempts to send a second response (200, 204, or 500), which triggers ERR_HTTP_HEADERS_SENT and crashes the server. The fix adds a return statement after the 501 send, consistent with the pattern used in the adjacent /tasks/:taskId/metadata endpoint and other early-exit guards in the same file. Added a test that verifies the 501 behavior with a GCS task store.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the A2A server where the GET /tasks/metadata endpoint would crash the server if a task store other than InMemoryTaskStore (e.g., GCSTaskStore) was configured. The fix ensures that the server gracefully handles this scenario by returning a 501 status and preventing subsequent response attempts, thereby improving the server's stability and reliability. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a server crash in the /tasks/metadata endpoint by adding a missing return statement after sending a 501 error. This prevents the code from attempting to send a second response, which previously caused an ERR_HTTP_HEADERS_SENT error. The fix is accompanied by a well-written test case that mocks the GCS task store and verifies that the endpoint now correctly returns a 501 status without crashing. The changes are correct and effectively resolve the issue.
|
Hi there! Thank you for your interest in contributing to Gemini CLI. To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383). We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'. This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community! |
Summary
Fixes #21729
Adds a missing
returnstatement after theres.status(501).send()in theGET /tasks/metadataendpoint. Without this return, when using a non-InMemory task store (e.g.,GCSTaskStore), the handler falls through into the try block and attempts to send a second response, causingERR_HTTP_HEADERS_SENTand crashing the server.Changes
packages/a2a-server/src/http/app.tsreturn;afterres.status(501).send()in the/tasks/metadataroute handler/tasks/:taskId/metadataendpoint and all other early-exit guards in the filepackages/a2a-server/src/http/endpoints.test.ts@google-cloud/storagemock to support GCS task store testingAgent Server Endpoints (GCS Task Store)describe blockGET /tasks/metadatareturns 501 (not crash) when using GCS task storeTesting
All 26 tests pass (6 endpoints + 20 app tests):
Impact
GET /tasks/metadatacall crashes A2A server whenGCS_BUCKET_NAMEis set