{"record":{"id":"61c6c6c81291c65d","repo":"chenhg5/cc-connect","slug":"cc-connect-binary-not-found-in-zip-archive","errorCode":null,"errorMessage":"cc-connect binary not found in zip archive","messagePattern":"cc-connect binary not found in zip archive","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/updater.go","lineNumber":242,"sourceCode":"}\n\nfunc extractBinaryFromZip(data []byte) ([]byte, error) {\n\tr, err := zip.NewReader(bytes.NewReader(data), int64(len(data)))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, f := range r.File {\n\t\tname := filepath.Base(f.Name)\n\t\tif strings.HasPrefix(name, \"cc-connect\") && !f.FileInfo().IsDir() {\n\t\t\trc, err := f.Open()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tdefer rc.Close()\n\t\t\treturn io.ReadAll(rc)\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"cc-connect binary not found in zip archive\")\n}\n\nfunc replaceBinary(newBinary []byte) error {\n\texecPath, err := os.Executable()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get executable path: %w\", err)\n\t}\n\texecPath, err = filepath.EvalSymlinks(execPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"resolve symlinks: %w\", err)\n\t}\n\n\tdir := filepath.Dir(execPath)\n\ttmpFile, err := os.CreateTemp(dir, \"cc-connect-update-*\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create temp file: %w\", err)\n\t}\n\ttmpPath := tmpFile.Name()","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/updater.go#L224-L260","documentation":"extractBinaryFromZip scans the downloaded zip's entries and returns this error when no file entry whose basename starts with \"cc-connect\" is found. The downloaded zip is valid but lacks the expected binary member.","triggerScenarios":"SelfUpdate routed a zip archive to extraction and every f.Name's basename failed the strings.HasPrefix(name, \"cc-connect\") check, or the matching entry is a directory: wrong artifact (docs/source zip), binary renamed inside the archive, empty zip, or only directory entries.","commonSituations":"Windows/macOS release asset changed its internal binary name; user hand-built and zipped artifacts with a different name; download URL pointing to the wrong platform's bundle; interrupted/zero-byte upload producing an empty zip.","solutions":["Run `unzip -l <archive>` to list members and verify a file starting with cc-connect exists at some depth.","Fix the release packaging so the binary member is named cc-connect* (zip is used for zip archives regardless of a .tar.gz extension mismatch).","If the binary is inside the zip but under a new name, update the updater's HasPrefix match accordingly.","Re-download from the official release URL — a mirror may host repackaged archives with renamed binaries.","Manual fallback: unzip, rename the binary to cc-connect, and replace the installed executable yourself."],"exampleFix":"// packaging: before\nzip cc-connect-windows-amd64.zip agent.exe\n// after\nzip cc-connect-windows-amd64.zip cc-connect.exe","handlingStrategy":"validation","validationCode":"r, err := zip.OpenReader(archivePath)\nif err == nil {\n    found := false\n    for _, f := range r.File {\n        if strings.HasPrefix(filepath.Base(f.Name), \"cc-connect\") {\n            found = true\n        }\n    }\n    if !found {\n        return fmt.Errorf(\"zip lacks cc-connect binary\")\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["List zip members (unzip -l) in release CI before publishing","Never rename the inner binary when repackaging","Keep one canonical packaging script per OS"],"tags":["archive","zip","self-update"],"backgroundTag":"resource-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}