{"record":{"id":"f68abc6386cfaa0c","repo":"apache/beam","slug":"could-not-read-request-body-w","errorCode":null,"errorMessage":"could not read request body: %w","messagePattern":"could not read request body: %w","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"sdks/go/pkg/beam/runners/prism/internal/web/web.go","lineNumber":389,"sourceCode":"}\n\ntype jobCancelHandler struct {\n\tJobcli jobpb.JobServiceClient\n}\n\ntype cancelJobRequest struct {\n\tJobID string `json:\"job_id\"`\n}\n\nfunc (h *jobCancelHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tvar cancelRequest *cancelJobRequest\n\tif r.Method != http.MethodPost {\n\t\thttp.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\tbody, err := io.ReadAll(r.Body)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"could not read request body: %w\", err)\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\tif len(body) == 0 {\n\t\thttp.Error(w, \"empty request body\", http.StatusBadRequest)\n\t\treturn\n\t}\n\tif err := json.Unmarshal(body, &cancelRequest); err != nil {\n\t\terr = fmt.Errorf(\"error parsing JSON: %s of request: %w\", body, err)\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// Forward JobId from POST body avoids direct json Unmarshall on composite types containing protobuf message types.\n\tresp, err := h.Jobcli.Cancel(r.Context(), &jobpb.CancelJobRequest{\n\t\tJobId: cancelRequest.JobID,\n\t})\n\tif err != nil {","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/prism/internal/web/web.go#L371-L407","documentation":"Error built in the jobCancelHandler's ServeHTTP when io.ReadAll on the request body fails (client disconnect, connection reset, oversized body rejected). The handler wraps the underlying I/O error and returns it to the HTTP client as a 400 Bad Request response.","triggerScenarios":"Thrown at sdks/go/pkg/beam/runners/prism/internal/web/web.go:389 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the cancel request with a well-formed HTTP client and a non-empty body","Ensure no proxy/client truncates the request body"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}