{"record":{"id":"b8f2856c955cea6f","repo":"twpayne/chezmoi","slug":"s-w","errorCode":null,"errorMessage":"%s: %w","messagePattern":"%s: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/chezmoi/archivereadersystem.go","lineNumber":63,"sourceCode":"\t\t\tcomponents := name.SplitAll()\n\t\t\tif len(components) <= options.StripComponents {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tname = NewRelPathFromComponents(components[options.StripComponents:]...)\n\t\t}\n\t\tif name.IsEmpty() {\n\t\t\treturn nil\n\t\t}\n\t\tnameAbsPath := options.RootAbsPath.Join(name)\n\n\t\ts.fileInfos[nameAbsPath] = fileInfo\n\t\tswitch {\n\t\tcase fileInfo.IsDir():\n\t\t\t// Do nothing.\n\t\tcase fileInfo.Mode()&fs.ModeType == 0:\n\t\t\tcontents, err := io.ReadAll(r)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"%s: %w\", name, err)\n\t\t\t}\n\t\t\ts.contents[nameAbsPath] = contents\n\t\tcase fileInfo.Mode()&fs.ModeType == fs.ModeSymlink:\n\t\t\ts.linkname[nameAbsPath] = linkname\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"%s: unsupported mode %o\", name, fileInfo.Mode()&fs.ModeType)\n\t\t}\n\t\treturn nil\n\t}); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn s, nil\n}\n\n// FileInfos returns s's fs.FileInfos.\nfunc (s *ArchiveReaderSystem) FileInfos() map[AbsPath]fs.FileInfo {\n\treturn s.fileInfos","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/twpayne/chezmoi/blob/f901167e4685db90da56d6a2a19df642cb3e0247/internal/chezmoi/archivereadersystem.go#L45-L81","documentation":"In archiveReaderSystem (internal/chezmoi/archivereadersystem.go:63), while walking an archive, entries are stored by kind: directories skipped, regular files read into contents, symlinks recorded as linknames. Any error reading a regular file's contents is wrapped as \"%s: %w\" with the entry name.","triggerScenarios":"WalkFile on an archive reader system encounters a regular-file entry whose underlying reader fails mid-read (io.ReadAll error), e.g. truncated or corrupt archive data.","commonSituations":"Partially downloaded or truncated archive; I/O failure reading from a network stream passed to readArchive; corrupted compressed stream (bad gzip/zstd data).","solutions":["Re-download or regenerate the archive; verify checksum/size.","Test archive integrity with `gzip -t`, `zstd -t`, or `tar -tf` before use.","If reading from a network source, retry the fetch and check for connection issues."],"exampleFix":"// before\nsys.ReadArchive(badReader)\n// after\ndata, err := io.ReadAll(resp.Body)\nif err != nil { return err }\nsys.ReadArchive(bytes.NewReader(data))","handlingStrategy":"try-catch","validationCode":"// Verify archive integrity before reading\nif err := verifyChecksum(archivePath); err != nil {\n    return fmt.Errorf(\"archive corrupt: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := sys.ReadArchive(r); err != nil {\n    // wrapped \"%s: %w\" — log entry name, re-fetch archive, retry once\n    return fmt.Errorf(\"archive read failed: %w\", err)\n}","preventionTips":["Verify archive checksums/size before processing.","Fully download network archives into memory/disk before reading.","Test compressed streams with gzip -t / zstd -t."],"tags":["archive","io","read-failure"],"backgroundTag":"archive-read-failed","analyzedSha":"f901167e4685db90da56d6a2a19df642cb3e0247","analyzedAt":"2026-09-01T18:16:41.508Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}