goharbor/harbor · error

unsupported format

Error message

unsupported format: %s

What it means

Guard error from decodeContent in the CNAI parser util: the media type's file extension does not match a supported format (tar or raw). The input at fault is the layer media type whose filepath.Ext falls through the switch, so the stream is never decoded.

Solutions

  1. Push the layer with a supported media type (tar or raw).
  2. Add the format to decodeContent's switch if a new media type must be supported.
  3. Check that annotations/mediaType on the manifest are not misspelled.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/controller/artifact/processor/cnai/parser/base.go:106 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/1a8b9371034b3377. Report an issue: GitHub.

Appendix: source

Thrown at src/controller/artifact/processor/cnai/parser/base.go:106

	content, err := decodeContent(layer.MediaType, stream, defaultFileSizeLimit)
	if err != nil {
		return "", nil, fmt.Errorf("failed to decode content: %w", err)
	}

	return contentTypeTextPlain, content, nil
}

// decodeContent decodes the content read from reader according to mediaType,
// enforcing that no more than limit bytes are materialized in memory.
func decodeContent(mediaType string, reader io.Reader, limit int64) ([]byte, error) {
	format := filepath.Ext(mediaType)
	switch format {
	case formatTar:
		return untar(reader, limit)
	case formatRaw:
		return readAllLimited(reader, limit)
	default:
		return nil, fmt.Errorf("unsupported format: %s", format)
	}
}

// readAllLimited reads from reader until EOF, but fails once more than limit
// bytes have been read.
func readAllLimited(reader io.Reader, limit int64) ([]byte, error) {
	if limit < 0 {
		return nil, fmt.Errorf("invalid limit: %d", limit)
	}

	// Read up to limit+1 bytes so we can distinguish "exactly at the limit"
	// from "over the limit".
	content, err := io.ReadAll(io.LimitReader(reader, limit+1))
	if err != nil {
		return nil, err
	}

	if int64(len(content)) > limit {

View on GitHub (pinned to 7b2fd08cc5)