goharbor/harbor · error

invalid content range format

Error message

invalid content range format, %s

What it means

Returned by parseContentRange when the Range header value from a registry upload-status response does not have exactly one '-' separator (e.g. 'start-end'). The registry returned a malformed or missing Range header, so the uploaded byte offset cannot be determined. The input at fault is the Range header string from the response.

Solutions

  1. Inspect the raw Range header the registry returned
  2. Verify the registry implements the Docker Registry v2 blob upload spec correctly
  3. Restart the blob upload if the session state is corrupt
  4. Report the non-conforming registry implementation if it persists
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/pkg/registry/client.go:493 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/9f9443855d76641d. Report an issue: GitHub.

Appendix: source

Thrown at src/pkg/registry/client.go:493

	resp, err := c.do(req)
	if err != nil {
		return location, -1, err
	}

	defer resp.Body.Close()

	_, end, err := parseContentRange(resp.Header.Get("Range"))
	if err != nil {
		return location, -1, err
	}

	return resp.Header.Get("Location"), end, nil
}

func parseContentRange(cr string) (int64, int64, error) {
	ranges := strings.Split(cr, "-")
	if len(ranges) != 2 {
		return -1, -1, fmt.Errorf("invalid content range format, %s", cr)
	}
	start, err := strconv.ParseInt(ranges[0], 10, 64)
	if err != nil {
		return -1, -1, err
	}
	end, err := strconv.ParseInt(ranges[1], 10, 64)
	if err != nil {
		return -1, -1, err
	}

	return start, end, nil
}

func (c *client) initiateBlobUpload(repository string) (string, string, error) {
	req, err := http.NewRequest(http.MethodPost, buildInitiateBlobUploadURL(c.url, repository), nil)
	if err != nil {
		return "", "", err
	}

View on GitHub (pinned to 7b2fd08cc5)