{"record":{"id":"3d02c154aa9cb767","repo":"googleapis/mcp-toolbox","slug":"failed-to-read-response-body-w-3d02c1","errorCode":null,"errorMessage":"failed to read response body: %w","messagePattern":"failed to read response body: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/firestore/firestore.go","lineNumber":932,"sourceCode":"\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(bodyBytes))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create HTTP request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"User-Agent\", userAgent)\n\treq.Header.Set(\"x-goog-request-params\", fmt.Sprintf(\"project_id=%s&database_id=%s\", s.GetProjectId(), s.GetDatabaseId()))\n\treq.Header.Set(\"x-goog-firestore-api-requester\", \"querydata\")\n\n\tresp, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to execute pipeline request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read response body: %w\", err)\n\t}\n\n\tif resp.StatusCode < 200 || resp.StatusCode >= 300 {\n\t\treturn nil, fmt.Errorf(\"executePipeline API error (status %d): %s\", resp.StatusCode, string(respBody))\n\t}\n\n\tvar result any\n\tif err := json.Unmarshal(respBody, &result); err != nil {\n\t\treturn string(respBody), nil\n\t}\n\n\treturn result, nil\n}\n\nfunc initFirestoreConnection(\n\tctx context.Context,\n\ttracer trace.Tracer,\n\tname string,","sourceCodeStart":914,"sourceCodeEnd":950,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/firestore/firestore.go#L914-L950","documentation":"This error wraps a failure from io.ReadAll(resp.Body) in ExecuteMQL — the HTTP request succeeded and got a response, but the response body could not be fully read. This is rare and usually indicates the connection was reset or timed out mid-transfer, or the response body reader errored.","triggerScenarios":"io.ReadAll(resp.Body) returns non-nil err after httpClient.Do succeeded: the connection dropped while streaming the response, a decompression/reading error occurred, or the deadline expired during body read.","commonSituations":"Very large pipeline result sets truncated by an intermediate proxy; flaky network dropping keep-alive connections mid-body; timeout elapsing between receiving headers and finishing the body.","solutions":["Retry the request — transient body-read failures usually resolve on a second attempt","Check for proxies/load balancers truncating responses and increase their timeouts","Increase the HTTP client/context timeout so large responses can finish streaming"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"res, err := src.ExecuteMQL(ctx, pipeline)\nif err != nil && strings.Contains(err.Error(), \"failed to read response body\") {\n    // transient: safe to retry the whole request\n    res, err = src.ExecuteMQL(ctx, pipeline)\n}","preventionTips":["Retry idempotent pipeline reads on body-read failures","Check proxy/load-balancer timeouts for large responses","Increase client/context timeout so the body can fully stream"],"tags":["firestore","http","io","response-body"],"backgroundTag":"network-request-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}