{"record":{"id":"b8a51c7bb5f14f5d","repo":"goharbor/harbor","slug":"failed-to-read-tar-header-w","errorCode":null,"errorMessage":"failed to read tar header: %w","messagePattern":"failed to read tar header: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/controller/artifact/processor/cnai/parser/util.go","lineNumber":80,"sourceCode":"\tif limit < 0 {\n\t\treturn nil, fmt.Errorf(\"invalid limit: %d\", limit)\n\t}\n\n\t// Cap the raw bytes consumed from the underlying stream as well: the\n\t// manifest-declared blob size can lie, and tar.Reader.Next() materializes\n\t// metadata (PAX extended records, GNU sparse maps) in memory before the\n\t// per-entry content copy below ever sees it.\n\ttr := tar.NewReader(&limitedReader{r: reader, remaining: limit + maxTarMetadataOverhead})\n\tvar buf bytes.Buffer\n\tremaining := limit\n\tfor {\n\t\theader, err := tr.Next()\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to read tar header: %w\", err)\n\t\t}\n\n\t\t// skip the directory.\n\t\tif header.Typeflag == tar.TypeDir {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Copy at most remaining+1 bytes so we can detect when the cumulative\n\t\t// content exceeds the limit without trusting the declared header size.\n\t\tn, err := io.Copy(&buf, io.LimitReader(tr, remaining+1))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to copy content to buffer: %w\", err)\n\t\t}\n\n\t\tremaining -= n\n\t\tif remaining < 0 {\n\t\t\treturn nil, errors.RequestEntityTooLargeError(errFileTooLarge)\n\t\t}","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/controller/artifact/processor/cnai/parser/util.go#L62-L98","documentation":"Error \"failed to read tar header: %w\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/controller/artifact/processor/cnai/parser/util.go:80 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"}