{"record":{"id":"822aba42310786e1","repo":"goharbor/harbor","slug":"failed-to-read-request-body","errorCode":null,"errorMessage":"failed to read request body","messagePattern":"failed to read request body","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"src/server/middleware/log/log.go","lineNumber":58,"sourceCode":"\t\t}\n\n\t\ttraceID := tracelib.ExractTraceID(r)\n\t\tif traceID != \"\" {\n\t\t\tctx := log.WithLogger(r.Context(), log.G(r.Context()).WithFields(log.Fields{\"traceID\": traceID}))\n\t\t\tr = r.WithContext(ctx)\n\t\t}\n\n\t\te := &commonevent.Metadata{\n\t\t\tCtx:           r.Context(),\n\t\t\tUsername:      \"unknown\",\n\t\t\tRequestMethod: r.Method,\n\t\t\tRequestURL:    r.URL.String(),\n\t\t}\n\t\tif matched, resName := e.PreCheckMetadata(); matched {\n\t\t\tlib.NopCloseRequest(r)\n\t\t\tbody, err := io.ReadAll(r.Body)\n\t\t\tif err != nil {\n\t\t\t\thttp.Error(w, \"failed to read request body\", http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t\trequestContent := string(body)\n\t\t\tif secCtx, ok := security.FromContext(r.Context()); ok {\n\t\t\t\te.Username = secCtx.GetUsername()\n\t\t\t}\n\t\t\trw := &ResponseWriter{\n\t\t\t\tResponseWriter: w,\n\t\t\t\tstatusCode:     http.StatusOK,\n\t\t\t}\n\t\t\tnext.ServeHTTP(rw, r)\n\n\t\t\t// Add information in the response\n\t\t\te.ResourceName = resName\n\t\t\te.RequestPayload = requestContent\n\t\t\te.ResponseCode = rw.statusCode\n\n\t\t\t// Need to parse the Location header to get the resource ID on creating resource","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/server/middleware/log/log.go#L40-L76","documentation":"Error \"failed to read request body\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/server/middleware/log/log.go:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}