{"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":"Error \"failed to decode content: %w\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/controller/artifact/processor/cnai/parser/base.go:90 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"}