{"record":{"id":"e0a809f534e0614e","repo":"goharbor/harbor","slug":"failed-to-decode-content-w","errorCode":null,"errorMessage":"failed to decode content: %w","messagePattern":"failed to decode content: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/controller/artifact/processor/cnai/parser/base.go","lineNumber":90,"sourceCode":"\t// size, which can be far smaller than the number of bytes materialized when\n\t// the content is decompressed/expanded (e.g. GNU tar sparse files).\n\tif layer.Size > defaultFileSizeLimit {\n\t\treturn \"\", nil, errors.RequestEntityTooLargeError(errFileTooLarge)\n\t}\n\n\t_, stream, err := b.regCli.PullBlob(artifact.RepositoryName, layer.Digest.String())\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"failed to pull blob from registry: %w\", err)\n\t}\n\n\tdefer stream.Close()\n\n\t// Enforce the size limit against the actual bytes materialized, not just the\n\t// declared blob size, to prevent decompression/sparse-file bombs from\n\t// exhausting memory.\n\tcontent, err := decodeContent(layer.MediaType, stream, defaultFileSizeLimit)\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"failed to decode content: %w\", err)\n\t}\n\n\treturn contentTypeTextPlain, content, nil\n}\n\n// decodeContent decodes the content read from reader according to mediaType,\n// enforcing that no more than limit bytes are materialized in memory.\nfunc decodeContent(mediaType string, reader io.Reader, limit int64) ([]byte, error) {\n\tformat := filepath.Ext(mediaType)\n\tswitch format {\n\tcase formatTar:\n\t\treturn untar(reader, limit)\n\tcase formatRaw:\n\t\treturn readAllLimited(reader, limit)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported format: %s\", format)\n\t}\n}","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/controller/artifact/processor/cnai/parser/base.go#L72-L108","documentation":"Wrapping error in base.Parse emitted after PullBlob succeeds but decodeContent fails. Causes include an unsupported media type, corrupted or non-conforming compressed stream, or the layer exceeding defaultFileSizeLimit during decompression; parsing of the layer content is abandoned.","triggerScenarios":"Thrown at src/controller/artifact/processor/cnai/parser/base.go:90 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the layer MediaType is one decodeContent supports (tar or raw).","Re-push the artifact if the blob content is corrupted.","Reduce the artifact size or raise the size limit if legitimate content exceeds it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","contentChangedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}