xpzouying/xiaohongshu-mcp · error
不支持的压缩格式: %s
Error message
不支持的压缩格式: %s
What it means
extractArchive dispatches on the archive filename suffix: .tar.xz, .zip, and .dmg are supported. This error is thrown when the downloaded archive has an extension none of these cases match, so the library refuses to guess how to unpack it.
Source
Thrown at browser/browser_download.go:217
f, err := os.Create(dst)
if err != nil {
return err
}
defer f.Close()
_, err = io.Copy(f, resp.Body)
return err
}
func extractArchive(archivePath, destDir string) error {
switch {
case strings.HasSuffix(archivePath, ".tar.xz"):
return extractTarXz(archivePath, destDir)
case strings.HasSuffix(archivePath, ".zip"):
return extractZip(archivePath, destDir)
case strings.HasSuffix(archivePath, ".dmg"):
return extractDmg(archivePath, destDir)
}
return fmt.Errorf("不支持的压缩格式: %s", archivePath)
}
func extractTarXz(archivePath, destDir string) error {
f, err := os.Open(archivePath)
if err != nil {
return err
}
defer f.Close()
xzr, err := xz.NewReader(f)
if err != nil {
return err
}
tr := tar.NewReader(xzr)
for {
hdr, err := tr.Next()
if err == io.EOF {
break
}View on GitHub (pinned to 332d196854)
Solutions
- Check the actual filename and `file` type of the downloaded archive in the cache directory
- Re-run EnsureBrowser after clearing the cache so a fresh, correctly named archive is downloaded
- If upstream switched formats, update the library or extend extractArchive with a case for the new suffix
- If a proxy is corrupting the response, bypass it for the download host
- Manually extract the archive into the expected destination directory and re-run to skip re-download
Example fix
// before
return fmt.Errorf("不支持的压缩格式: %s", archivePath)
// after — support the new format
case strings.HasSuffix(archivePath, ".tar.bz2"):
return extractTarBz2(archivePath, destDir)
default:
return fmt.Errorf("不支持的压缩格式: %s", archivePath) Defensive patterns
Strategy: validation
Validate before calling
switch {
case strings.HasSuffix(path, ".tar.xz"), strings.HasSuffix(path, ".zip"), strings.HasSuffix(path, ".dmg"):
// 支持的格式
default:
return fmt.Errorf("archive format not supported: %s", filepath.Ext(path))
} Try / catch
if err := EnsureBrowser(ctx); err != nil {
if strings.Contains(err.Error(), "不支持的压缩格式") {
// 清理缓存后重新下载,或手动解压到目标目录
os.RemoveAll(cacheDir)
err = EnsureBrowser(ctx)
}
if err != nil { return err }
} Prevention
- Clear the browser cache directory before retrying so a fresh archive is fetched
- Verify the downloaded file's type with `file` if extensions look odd
- Keep the library updated when upstream changes packaging
- Never rename/move cached archives manually
When it happens
Trigger: EnsureBrowser downloads a browser archive whose filename does not end in .tar.xz, .zip, or .dmg, then calls extractArchive(archivePath, destDir) which falls through all cases to the final fmt.Errorf.
Common situations: Upstream changed the packaging format (e.g. switched to .tar.bz2 or .7z); a proxy served a compressed or HTML response saved under an unexpected filename; the archive was manually placed/renamed in the cache directory; a new OS target ships a different archive type.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/076672e46393aee3.
Report an issue: GitHub.