{"record":{"id":"674a21f8dd011774","repo":"apache/beam","slug":"error-parsing-json-s-of-request-w","errorCode":null,"errorMessage":"error parsing JSON: %s of request: %w","messagePattern":"error parsing JSON: (.+?) of request: %w","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"sdks/go/pkg/beam/runners/prism/internal/web/web.go","lineNumber":398,"sourceCode":"\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 {\n\t\tstatusCode := status.Code(err)\n\t\thttpCode := http.StatusInternalServerError\n\t\tif c, ok := grpcToHttpCodes[statusCode]; ok {\n\t\t\thttpCode = c\n\t\t}\n\t\terr = fmt.Errorf(\"error Cancel(%+v) = %w\", cancelRequest, err)\n\t\thttp.Error(w, err.Error(), httpCode)\n\t}\n","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/prism/internal/web/web.go#L380-L416","documentation":"Error built in jobCancelHandler.ServeHTTP when json.Unmarshal of the POST body into cancelJobRequest fails — malformed JSON, wrong types, or trailing garbage. The raw body is echoed in the message to aid debugging, and the client receives HTTP 400.","triggerScenarios":"Thrown at sdks/go/pkg/beam/runners/prism/internal/web/web.go:398 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send a valid JSON object with a 'job_id' string field, e.g. {\"job_id\": \"...\"}","Remove trailing commas or extra data after the JSON object"],"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"}