jeessy2/ddns-go · error
%w tar.gz 文件: %s
Error message
%w tar.gz 文件: %s
What it means
untar first wraps the source in gzip.NewReader; if the stream is not valid gzip data, it returns errCannotDecompressFile wrapped with this message and the gzip error. It signals the downloaded .tar.gz artifact is not actually gzip-compressed.
Source
Thrown at util/update/decompress.go:67
z, err := zip.NewReader(r, r.Size())
if err != nil {
return nil, fmt.Errorf("%w zip 文件: %s", errCannotDecompressFile, err)
}
for _, file := range z.File {
_, name := filepath.Split(file.Name)
if !file.FileInfo().IsDir() && matchExecutableName(cmd, name) {
return file.Open()
}
}
return nil, fmt.Errorf("在 zip 文件中%w:%q", errExecutableNotFoundInArchive, cmd)
}
func untar(src io.Reader, cmd string) (io.Reader, error) {
gz, err := gzip.NewReader(src)
if err != nil {
return nil, fmt.Errorf("%w tar.gz 文件: %s", errCannotDecompressFile, err)
}
t := tar.NewReader(gz)
for {
h, err := t.Next()
if errors.Is(err, io.EOF) {
break
}
if err != nil {
return nil, fmt.Errorf("%w tar.gz 文件:%s", errCannotDecompressFile, err)
}
_, name := filepath.Split(h.Name)
if matchExecutableName(cmd, name) {
return t, nil
}
}
return nil, fmt.Errorf("在 tar.gz 文件中%w:%q", errExecutableNotFoundInArchive, cmd)
}View on GitHub (pinned to 5874c2e666)
Solutions
- Verify the downloaded file starts with the gzip magic bytes (1f 8b) and is a real .tar.gz
- Confirm the release URL serves the actual tar.gz asset, not an error page
- Re-download the asset; use errors.Is(err, errCannotDecompressFile) to identify this family
Defensive patterns
Strategy: validation
Validate before calling
// Check gzip magic bytes before untarring
head := make([]byte, 2)
if n, _ := io.ReadFull(src, head); n < 2 || head[0] != 0x1f || head[1] != 0x8b {
return fmt.Errorf("not gzip data")
} Try / catch
r, err := untar(src, cmd)
if err != nil {
if errors.Is(err, errCannotDecompressFile) {
log.Errorf("downloaded artifact is not valid tar.gz: %v", err)
return errCorruptAsset
}
return err
} Prevention
- Verify asset checksums after download before decompressing
- Check first bytes for the 0x1f 0x8b gzip magic
- Confirm the URL serves the real .tar.gz, not an error page
- Re-download truncated tarballs before retrying
When it happens
Trigger: Self-update downloads a .tar.gz asset whose bytes fail gzip.NewReader — server returned an HTML/text error page, the file is uncompressed tar, or the download was truncated/corrupted.
Common situations: Release URL pointing at an error page or wrong artifact; proxy stripping/altering content-encoding; partial download of a large tarball.
Related errors
AI-assisted analysis of jeessy2/ddns-go@5874c2e666 (2026-09-03).
Data as JSON: /api/errors/16c07ef1df930970.
Report an issue: GitHub.