{"record":{"id":"05e8a295f57c6ba8","repo":"twpayne/chezmoi","slug":"s-unknown-archive-format","errorCode":null,"errorMessage":"%s: unknown archive format","messagePattern":"(.+?): unknown archive format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/chezmoi/archive.go","lineNumber":119,"sourceCode":"\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\tcase ArchiveFormatTarXz:\n\t\t// Decompress with xz.\n\t\tvar err error\n\t\tr, err = xz.NewReader(r)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\tcase ArchiveFormatTarZst:\n\t\t// Decompress with zstd.\n\t\tvar err error\n\t\tr, err = zstd.NewReader(r)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"%s: unknown archive format\", format)\n\t}\n\treturn walkArchiveTar(r, f)\n}\n\n// isTarArchive returns if r looks like a tar archive.\nfunc isTarArchive(r io.Reader) bool {\n\ttarReader := tar.NewReader(r)\n\t_, err := tarReader.Next()\n\treturn err == nil\n}\n\nfunc implicitTarDirHeader(dir RelPath, modTime time.Time) *tar.Header {\n\treturn &tar.Header{\n\t\tTypeflag: tar.TypeDir,\n\t\tName:     dir.String(),\n\t\tMode:     0o777,\n\t\tSize:     0,\n\t\tModTime:  modTime,","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/twpayne/chezmoi/blob/f901167e4685db90da56d6a2a19df642cb3e0247/internal/chezmoi/archive.go#L101-L137","documentation":"WalkArchive (internal/chezmoi/archive.go:119) sniffs the archive's magic bytes and dispatches to the appropriate reader (tar, zip, gzip, bzip2, xz, zstd). If the detected format does not match any supported decompressor, it returns \"%s: unknown archive format\" naming the format identifier found.","triggerScenarios":"Calling WalkArchive (or readExternalArchive / NewArchiveReaderSystem which route through it) with data whose leading bytes match none of the supported magic numbers.","commonSituations":"Downloaded archive URL returned an HTML error page instead of an archive; file truncated or corrupted; using a compression format chezmoi does not support (e.g. lz4, 7z); empty file passed as an archive.","solutions":["Verify the file is actually an archive: run `file <path>` and check magic bytes.","Re-download or regenerate the archive; ensure the URL/fetch did not return an error page.","Convert the archive to a supported format (tar, tar.gz, tar.bz2, tar.xz, tar.zst, zip)."],"exampleFix":"# before: URL serving HTML login page\ncurl -sL $URL | chezmoi archive import -\n# after\ncurl -sfL $URL -o archive.tar.gz && file archive.tar.gz && chezmoi archive import archive.tar.gz","handlingStrategy":"validation","validationCode":"buf, _ := io.ReadAll(io.LimitReader(r, 512))\nmagic := http.DetectContentType(buf)\nif magic == \"text/html; charset=utf-8\" {\n    return fmt.Errorf(\"not an archive: got HTML\")\n}","typeGuard":null,"tryCatchPattern":"if err := chezmoi.WalkArchive(data, fn); err != nil {\n    if strings.Contains(err.Error(), \"unknown archive format\") {\n        // inspect `file` output and re-fetch or convert the archive\n    }\n    return err\n}","preventionTips":["Use `file` to verify archive type before processing.","Pin and checksum archive URLs to avoid downloading error pages.","Stick to supported formats: tar, tar.gz, tar.bz2, tar.xz, tar.zst, zip."],"tags":["archive","format-detection","io"],"backgroundTag":"unsupported-archive-format","analyzedSha":"f901167e4685db90da56d6a2a19df642cb3e0247","analyzedAt":"2026-09-01T18:16:41.508Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}