{"record":{"id":"39f8216497f8f971","repo":"micro/go-micro","slug":"agent-card-status-d","errorCode":null,"errorMessage":"agent card: status %d","messagePattern":"agent card: status (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gateway/a2a/client.go","lineNumber":52,"sourceCode":"\tif h != nil {\n\t\tc.http = h\n\t}\n\treturn c\n}\n\n// Card fetches the remote agent's Agent Card.\nfunc (c *Client) Card(ctx context.Context) (*AgentCard, error) {\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, c.url+\"/.well-known/agent.json\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresp, err := c.http.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"agent card: status %d\", resp.StatusCode)\n\t}\n\tvar card AgentCard\n\tif err := json.NewDecoder(resp.Body).Decode(&card); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &card, nil\n}\n\n// Send sends a text message to the remote agent and returns its reply.\n// If the agent returns a task that isn't yet terminal, Send polls\n// tasks/get until it completes or ctx is done.\nfunc (c *Client) Send(ctx context.Context, text string) (string, error) {\n\ttask, err := c.SendMessage(ctx, Message{\n\t\tRole:      \"user\",\n\t\tKind:      \"message\",\n\t\tMessageID: uuid.New().String(),\n\t\tParts:     []Part{{Kind: \"text\", Text: text}},\n\t})","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/gateway/a2a/client.go#L34-L70","documentation":"Card fetches the remote agent's A2A agent card (well-known JSON document) over HTTP. The library throws this error when the HTTP response status is anything other than 200 OK, because a non-200 response means no valid agent card body can be decoded. It wraps only the status code, not the body, so the actual server-side reason (404, 401, 502, etc.) must be inferred from the number.","triggerScenarios":"Calling Card() on an agent whose /.well-known/agent.json (or configured card URL) returns 404 Not Found, 401/403 auth failure, 500 server error, or a proxy/gateway 502/503 response instead of the card JSON.","commonSituations":"Wrong base URL or port for the agent endpoint; agent service not deployed or crashed behind a load balancer; missing auth token for a protected discovery endpoint; reverse proxy routing the well-known path incorrectly.","solutions":["Verify the agent card URL is correct and reachable (curl the endpoint and confirm 200 + JSON).","Check that the agent service is running and registered behind the gateway/proxy.","If the endpoint requires authentication, configure the client's HTTP transport/headers before calling Card().","Inspect the status code in the error message to distinguish not-found (404) from auth (401/403) or upstream failure (5xx)."],"exampleFix":"// before\nresp, err := http.Get(\"https://agents.internal:9443\")\ncard, err := client.Card(ctx)\n// after\n// point the client at the full agent base URL whose well-known path serves the card\ncard, err := client.Card(ctx) // client base: https://agents.internal:9443/a2a/finance","handlingStrategy":"try-catch","validationCode":"resp, err := http.Get(agentBase + \"/.well-known/agent.json\")\nif err != nil { return err }\nif resp.StatusCode != http.StatusOK {\n\treturn fmt.Errorf(\"agent card endpoint returned %d\", resp.StatusCode)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"card, err := c.Card(ctx)\nif err != nil {\n\tif strings.Contains(err.Error(), \"status \") {\n\t\t// inspect/parse status code; retry on 5xx, fail fast on 4xx\n\t}\n\treturn err\n}","preventionTips":["Health-check the card endpoint in readiness probes","Configure auth transport for protected discovery endpoints","Pin the correct agent base URL in config, not per-call","Alert on 5xx from discovery endpoints"],"tags":["network","http","a2a","discovery"],"backgroundTag":"http-non-200-response","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}