{"record":{"id":"69aa66ea5788dcd8","repo":"mastra-ai/mastra","slug":"a2a-json-rpc-response-did-not-include-a-result","errorCode":null,"errorMessage":"A2A JSON-RPC response did not include a result","messagePattern":"A2A JSON-RPC response did not include a result","errorType":"exception","errorClass":"MastraClientErrorClass","httpStatus":200,"severity":"error","filePath":"client-sdks/client-js/src/resources/a2a.ts","lineNumber":88,"sourceCode":"\nfunction createA2AJsonRpcError(response: JSONRPCErrorResponse): Error {\n  const error = response.error;\n  const message = error?.message ?? 'Unknown A2A JSON-RPC error';\n  return typeof error?.code === 'number'\n    ? new MastraA2AError(error.code, message, error.data)\n    : new MastraClientErrorClass(200, 'OK', `A2A JSON-RPC error - ${message}`, error);\n}\n\nfunction unwrapA2AResult<TResult>(response: JSONRPCResponse): TResult {\n  if ('error' in response && response.error) {\n    throw createA2AJsonRpcError(response as JSONRPCErrorResponse);\n  }\n\n  if ('result' in response) {\n    return response.result as TResult;\n  }\n\n  throw new MastraClientErrorClass(200, 'OK', 'A2A JSON-RPC response did not include a result', response);\n}\n\nasync function requireResponseBody(response: Response, method: string): Promise<ReadableStream<Uint8Array>> {\n  if (response.body) {\n    return response.body;\n  }\n\n  const headerSummary = Array.from(response.headers.entries())\n    .map(([key, value]) => `${key}: ${value}`)\n    .join(', ');\n\n  let responseText = '';\n  try {\n    responseText = await response.text();\n  } catch {\n    // Ignore body read failures and surface the rest of the response context.\n  }\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/client-sdks/client-js/src/resources/a2a.ts#L70-L106","documentation":"A2A JSON-RPC responses must carry either a `result` (success) or an `error`. unwrapA2AResult throws a MastraClientError when a 200 response contains neither — the server returned a malformed JSON-RPC payload, so the client refuses to return undefined to callers.","triggerScenarios":"Any A2A RPC call (rpc, getExtendedAgentCard, task push-notification config get/set/list/delete) where the server responds 200 with JSON lacking both 'result' and a handled 'error' field — e.g. an A2A server bug, a non-JSON-RPC proxy response, or an error payload shape the client doesn't recognize.","commonSituations":"Pointing the A2A client at an endpoint that isn't a compliant A2A server (HTML error page behind a 200, gateway response); version mismatch between client and server JSON-RPC envelope.","solutions":["Log response.error — the MastraClientError includes the full response payload; check for a JSON-RPC error object the client didn't map.","Verify the A2A server URL points at a compliant A2A JSON-RPC endpoint.","Upgrade/align client and server versions so the JSON-RPC envelope matches.","Inspect any proxy/gateway that could rewrite the response body."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isJsonRpcSuccess<T>(r: unknown): r is { result: T } {\n  return typeof r === 'object' && r !== null && 'result' in r;\n}","tryCatchPattern":"try {\n  const card = await a2a.getExtendedAgentCard();\n} catch (e) {\n  if (e instanceof MastraClientError && e.message.includes('did not include a result')) {\n    // inspect e.response for a JSON-RPC error object or non-JSON-RPC payload\n  }\n  throw e;\n}","preventionTips":["Point the A2A client only at compliant A2A JSON-RPC endpoints.","Keep client and server protocol versions aligned.","Log the full response payload from MastraClientError for diagnosis."],"tags":["a2a","json-rpc","protocol"],"backgroundTag":"malformed-json-rpc-response","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}