goharbor/harbor · error

failed to read request body

Error message

failed to read request body

What it means

Error "failed to read request body" thrown in goharbor/harbor.

Source

Thrown at src/server/middleware/log/log.go:58

		}

		traceID := tracelib.ExractTraceID(r)
		if traceID != "" {
			ctx := log.WithLogger(r.Context(), log.G(r.Context()).WithFields(log.Fields{"traceID": traceID}))
			r = r.WithContext(ctx)
		}

		e := &commonevent.Metadata{
			Ctx:           r.Context(),
			Username:      "unknown",
			RequestMethod: r.Method,
			RequestURL:    r.URL.String(),
		}
		if matched, resName := e.PreCheckMetadata(); matched {
			lib.NopCloseRequest(r)
			body, err := io.ReadAll(r.Body)
			if err != nil {
				http.Error(w, "failed to read request body", http.StatusInternalServerError)
				return
			}
			requestContent := string(body)
			if secCtx, ok := security.FromContext(r.Context()); ok {
				e.Username = secCtx.GetUsername()
			}
			rw := &ResponseWriter{
				ResponseWriter: w,
				statusCode:     http.StatusOK,
			}
			next.ServeHTTP(rw, r)

			// Add information in the response
			e.ResourceName = resName
			e.RequestPayload = requestContent
			e.ResponseCode = rw.statusCode

			// Need to parse the Location header to get the resource ID on creating resource

View on GitHub (pinned to 7b2fd08cc5)

When it happens

Trigger: Thrown at src/server/middleware/log/log.go:58 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/822aba42310786e1. Report an issue: GitHub.