{"record":{"id":"8ad48c1c61f1af97","repo":"jeessy2/ddns-go","slug":"zip-w-q","errorCode":null,"errorMessage":"在 zip 文件中%w：%q","messagePattern":"在 zip 文件中%w：%q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/update/decompress.go","lineNumber":61,"sourceCode":"\tbuf, err := io.ReadAll(src)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%w zip 文件: %v\", errCannotDecompressFile, err)\n\t}\n\n\tr := bytes.NewReader(buf)\n\tz, err := zip.NewReader(r, r.Size())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%w zip 文件: %s\", errCannotDecompressFile, err)\n\t}\n\n\tfor _, file := range z.File {\n\t\t_, name := filepath.Split(file.Name)\n\t\tif !file.FileInfo().IsDir() && matchExecutableName(cmd, name) {\n\t\t\treturn file.Open()\n\t\t}\n\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)","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/util/update/decompress.go#L43-L79","documentation":"unzip successfully opened a valid zip archive but no non-directory entry whose filename matches the executable name (matchExecutableName) was found, so it returns errExecutableNotFoundInArchive wrapped in this message along with the command name. The archive is fine; it simply doesn't contain the expected binary.","triggerScenarios":"Self-update downloads a zip release that lacks a file matching the current executable's name — wrong architecture asset (e.g. arm64 zip on amd64), a source-only zip, or the project renamed its binary between releases.","commonSituations":"Selecting the wrong platform asset in release downloads; upstream renamed the executable in a newer release; downloading a source-code zip instead of the built release zip.","solutions":["Download the zip asset matching your OS/architecture that contains the binary","List the zip contents (unzip -l) and compare entry names against the expected executable name","Check upstream release notes for binary renames and update the expected name/matching logic"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Optionally inspect the archive listing before extraction\nzr, err := zip.OpenReader(path)\nif err != nil { return err }\nfor _, f := range zr.File {\n    if strings.HasSuffix(f.Name, executableName) { return nil }\n}\nreturn fmt.Errorf(\"%s not present in archive\", executableName)","typeGuard":null,"tryCatchPattern":"r, err := unzip(src, cmd)\nif err != nil {\n    if errors.Is(err, errExecutableNotFoundInArchive) {\n        // wrong platform asset or renamed binary: surface actionable message\n        return fmt.Errorf(\"update asset does not contain %q; check OS/arch of the release\", cmd)\n    }\n    return err\n}","preventionTips":["Select release assets matching your GOOS/GOARCH","Track upstream binary renames in release notes","Avoid source-code zips; use built release artifacts","List archive contents when debugging update failures"],"tags":["zip","executable-not-found","update"],"backgroundTag":"executable-not-found-in-archive","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"}