{"record":{"id":"026f0c3a79d96802","repo":"jeessy2/ddns-go","slug":"w-tar-gz-s-026f0c","errorCode":null,"errorMessage":"%w tar.gz 文件：%s","messagePattern":"%w tar\\.gz 文件：(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/update/decompress.go","lineNumber":77,"sourceCode":"\t}\n\n\treturn nil, fmt.Errorf(\"在 zip 文件中%w：%q\", errExecutableNotFoundInArchive, cmd)\n}\n\nfunc untar(src io.Reader, cmd string) (io.Reader, error) {\n\tgz, err := gzip.NewReader(src)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%w tar.gz 文件: %s\", errCannotDecompressFile, err)\n\t}\n\n\tt := tar.NewReader(gz)\n\tfor {\n\t\th, err := t.Next()\n\t\tif errors.Is(err, io.EOF) {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"%w tar.gz 文件：%s\", errCannotDecompressFile, err)\n\t\t}\n\t\t_, name := filepath.Split(h.Name)\n\t\tif matchExecutableName(cmd, name) {\n\t\t\treturn t, nil\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"在 tar.gz 文件中%w：%q\", errExecutableNotFoundInArchive, cmd)\n}\n\nfunc matchExecutableName(cmd, target string) bool {\n\treturn cmd == target || cmd+\".exe\" == target\n}\n","sourceCodeStart":59,"sourceCodeEnd":90,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/util/update/decompress.go#L59-L90","documentation":"untar reads successive entries from the tar stream; if t.Next returns a non-EOF error (corrupt tar headers, truncated data, checksum mismatch), it returns errCannotDecompressFile wrapped with this message. The gzip layer succeeded but the inner tar structure is unreadable.","triggerScenarios":"Self-update processes a .tar.gz whose gzip stream decompresses but whose tar payload is corrupt — truncated download, bit-flip in transit, or a file that is gzip but not tar.","commonSituations":"Interrupted downloads saved as complete; flaky network/proxy corrupting large tarballs; mislabeled assets that are gzip-only or in a different archive format.","solutions":["Re-download the .tar.gz and verify its checksum against the published checksum file","Confirm the asset is a tar archive (tar -tzf file.tar.gz locally)","Check disk space and integrity of the storage path; use errors.Is(err, errCannotDecompressFile) to confirm"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Verify checksum of the downloaded archive before extraction\nsum := sha256.Sum256(buf)\nif !checksumMatches(hex.EncodeToString(sum[:])) {\n    return fmt.Errorf(\"archive checksum mismatch\")\n}","typeGuard":null,"tryCatchPattern":"r, err := untar(src, cmd)\nif err != nil {\n    if errors.Is(err, errCannotDecompressFile) {\n        // corrupt tar payload: re-download and retry once\n        return retryDownload(archiveURL, cmd)\n    }\n    return err\n}","preventionTips":["Verify published checksums before extracting","Re-download archives on any extraction error rather than reusing buffers","Avoid interrupted downloads being treated as complete","Watch disk space — full disks corrupt written archives"],"tags":["tar","gzip","decompression","corrupt-archive"],"backgroundTag":"archive-decompression-failed","analyzedSha":"5874c2e6667c69357ab95079421131104bd3fcae","analyzedAt":"2026-09-03T15:41:16.799Z","contentChangedAt":"2026-09-03T15:41:16.799Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}