{"record":{"id":"2a3784e3e2b3d582","repo":"GoogleCloudPlatform/microservices-demo","slug":"failed-to-read-response","errorCode":null,"errorMessage":"failed to read response","messagePattern":"failed to read response","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"src/frontend/handlers.go","lineNumber":480,"sourceCode":"\tvar response LLMResponse\n\n\turl := \"http://\" + fe.shoppingAssistantSvcAddr\n\treq, err := http.NewRequest(http.MethodPost, url, r.Body)\n\tif err != nil {\n\t\trenderHTTPError(log, r, w, errors.Wrap(err, \"failed to create request\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Accept\", \"application/json\")\n\tres, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\trenderHTTPError(log, r, w, errors.Wrap(err, \"failed to send request\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tbody, err := io.ReadAll(res.Body)\n\tif err != nil {\n\t\trenderHTTPError(log, r, w, errors.Wrap(err, \"failed to read response\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tfmt.Printf(\"%+v\\n\", body)\n\tfmt.Printf(\"%+v\\n\", res)\n\n\terr = json.Unmarshal(body, &response)\n\tif err != nil {\n\t\trenderHTTPError(log, r, w, errors.Wrap(err, \"failed to unmarshal body\"), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// respond with the same message\n\tjson.NewEncoder(w).Encode(Response{Message: response.Content})\n\n\tw.WriteHeader(http.StatusOK)\n}\n","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/GoogleCloudPlatform/microservices-demo/blob/72ba613a05f7fcee51cf1d0badff401b6ae7074d/src/frontend/handlers.go#L462-L498","documentation":"io.ReadAll failed while reading the shopping assistant's response body after a successful send: the response stream broke mid-read (connection reset, truncated chunked response, or timeout during read).","triggerScenarios":"Thrown at src/frontend/handlers.go:480 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check assistant-side logs for panics or premature connection closes mid-response.","Set a client timeout long enough for the assistant's worst-case latency.","Retry the request on transient read errors.","Verify proxies/load balancers are not cutting long-lived responses."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"72ba613a05f7fcee51cf1d0badff401b6ae7074d","analyzedAt":"2026-09-02T01:15:09.673Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}