Bug Report
Description
The GET /tasks/metadata endpoint in packages/a2a-server/src/http/app.ts is missing a return statement after sending a 501 response when using a non-InMemory task store (e.g., GCSTaskStore). This causes the handler to fall through into the try block and attempt to send a second response, which triggers ERR_HTTP_HEADERS_SENT and crashes the server.
Steps to Reproduce
- Set
GCS_BUCKET_NAME environment variable (triggers GCSTaskStore)
- Start the A2A server
- Send
GET /tasks/metadata
- Server sends 501 response
- Code falls through to try block → sends 200/204/500
ERR_HTTP_HEADERS_SENT — server crashes
Root Cause
In packages/a2a-server/src/http/app.ts line ~324:
expressApp.get("/tasks/metadata", async (req, res) => {
if (!(taskStoreForExecutor instanceof InMemoryTaskStore)) {
res.status(501).send({
error: "Listing all task metadata is only supported when using InMemoryTaskStore.",
});
// ❌ Missing: return;
}
try {
// Falls through — sends a SECOND response
const wrappers = agentExecutor.getAllTasks();
...
res.status(200).json(tasksMetadata); // ERR_HTTP_HEADERS_SENT
Evidence
The adjacent /tasks/:taskId/metadata endpoint handles this correctly:
if (!wrapper) {
res.status(404).send({ error: "Task not found" });
return; // ✅ Correct pattern
}
Every other early-exit guard in the same file (handleExecuteCommand lines 161, 165, 170, 176) correctly uses return.
Impact
- Severity: Server crash (unhandled exception)
- Scope: All A2A server deployments using GCS persistence (
GCS_BUCKET_NAME set)
- Reproducibility: 100% — every call to
GET /tasks/metadata crashes the server
Proposed Fix
Add return; after the res.status(501).send() call (1-line fix). I have a PR ready.
Bug Report
Description
The
GET /tasks/metadataendpoint inpackages/a2a-server/src/http/app.tsis missing areturnstatement after sending a501response when using a non-InMemory task store (e.g.,GCSTaskStore). This causes the handler to fall through into thetryblock and attempt to send a second response, which triggersERR_HTTP_HEADERS_SENTand crashes the server.Steps to Reproduce
GCS_BUCKET_NAMEenvironment variable (triggersGCSTaskStore)GET /tasks/metadataERR_HTTP_HEADERS_SENT— server crashesRoot Cause
In
packages/a2a-server/src/http/app.tsline ~324:Evidence
The adjacent
/tasks/:taskId/metadataendpoint handles this correctly:Every other early-exit guard in the same file (
handleExecuteCommandlines 161, 165, 170, 176) correctly usesreturn.Impact
GCS_BUCKET_NAMEset)GET /tasks/metadatacrashes the serverProposed Fix
Add
return;after theres.status(501).send()call (1-line fix). I have a PR ready.