jeessy2/ddns-go · error

在 tar.gz 文件中%w:%q

Error message

在 tar.gz 文件中%w:%q

What it means

untar in util/update/decompress.go iterates a tar.gz archive looking for an entry whose base name matches the requested executable (matchExecutableName accepts exact match or cmd+".exe"). If no entry matches before the archive is exhausted, it returns this wrapped error combining errExecutableNotFoundInArchive with the requested command name. It signals that the downloaded archive does not contain the binary the updater expected.

Source

Thrown at util/update/decompress.go:84

	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)
}

func matchExecutableName(cmd, target string) bool {
	return cmd == target || cmd+".exe" == target
}

View on GitHub (pinned to 5874c2e666)

Solutions

  1. Verify the exact base name of the executable inside the tar.gz (tar -tzf file.tar.gz) and request that exact cmd.
  2. If the upstream binary was renamed, update the cmd passed to untar or the update configuration to the new name.
  3. Confirm you downloaded the archive for the correct OS/arch; a linux asset will not contain tool.exe or a matching name for a windows cmd.
  4. Check errExecutableNotFoundInArchive with errors.Is to distinguish this case from decompression failures and surface a clear message to users.

Example fix

// before
exe, err := untar(rc, "mytool")
// after (match actual archive entry)
exe, err := untar(rc, "mytool-bin") // archive contains mytool-bin / mytool-bin.exe
Defensive patterns

Strategy: try-catch

Try / catch

exe, err := untar(rc, cmd)
if err != nil {
	if errors.Is(err, errExecutableNotFoundInArchive) {
		return fmt.Errorf("binary %q missing from downloaded archive; verify release asset", cmd)
	}
	return err
}

Prevention

When it happens

Trigger: Calling untar (directly or via the update flow's downloadAssetFromURL/to path) with a cmd whose base name does not equal any tar entry's filepath.Split(h.Name) base name, nor cmd+".exe". E.g. archive ships bin/tool.gz, nested paths whose split base differs, or asking for the wrong command name.

Common situations: Upstream release renamed or repackaged the binary; updater config points at an old asset; Windows-vs-Linux naming mismatch (.exe only checked one way); archive layout changed so the binary sits under a directory with a different split base name.

Related errors


AI-assisted analysis of jeessy2/ddns-go@5874c2e666 (2026-09-03). Data as JSON: /api/errors/9e4fecea70676f64. Report an issue: GitHub.