{"record":{"id":"da3cccd22cbf33c6","repo":"apache/beam","slug":"error-encoding-response-w","errorCode":null,"errorMessage":"error encoding response: %w","messagePattern":"error encoding response: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"sdks/go/pkg/beam/runners/prism/internal/web/web.go","lineNumber":420,"sourceCode":"\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\n\tw.Header().Add(kContentType, kApplicationJson)\n\n\tif err = json.NewEncoder(w).Encode(resp); err != nil {\n\t\terr = fmt.Errorf(\"error encoding response: %w\", err)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n}\n\n// Initialize the web client to talk to the given Job Management Client.\nfunc Initialize(ctx context.Context, port int, jobcli jobpb.JobServiceClient) error {\n\tassetsFs := http.FileServer(http.FS(assets))\n\tmux := http.NewServeMux()\n\n\tmux.Handle(\"/assets/\", assetsFs)\n\tmux.Handle(\"/job/cancel/\", &jobCancelHandler{Jobcli: jobcli})\n\tmux.Handle(\"/job/\", &jobDetailsHandler{Jobcli: jobcli})\n\tmux.Handle(\"/debugz\", &debugzHandler{})\n\tmux.Handle(\"/\", &jobsConsoleHandler{Jobcli: jobcli})\n\n\tendpoint := fmt.Sprintf(\"localhost:%d\", port)\n\n\tslog.Info(\"Serving WebUI\", slog.String(\"endpoint\", \"http://\"+endpoint))","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/prism/internal/web/web.go#L402-L438","documentation":"Error built in jobCancelHandler.ServeHTTP when json.NewEncoder(w).Encode of the CancelJobResponse fails while writing the HTTP response — typically because the client disconnected mid-response or the connection was closed. The error can no longer be reported to that client, so it is wrapped and logged/surfaced server-side.","triggerScenarios":"Thrown at sdks/go/pkg/beam/runners/prism/internal/web/web.go:420 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check for client-side timeouts or early disconnects and retry the request","Ensure response body is fully consumed by the client"],"exampleFix":null,"handlingStrategy":"fallback","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"}