{"record":{"id":"eade0029b986776d","repo":"chenhg5/cc-connect","slug":"download-failed-from-all-sources-w","errorCode":null,"errorMessage":"download failed from all sources: %w","messagePattern":"download failed from all sources: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/updater.go","lineNumber":155,"sourceCode":"\tgiteeURL := fmt.Sprintf(\"%s/%s/%s\", giteeDownload, tag, filename)\n\tgithubURL := fmt.Sprintf(\"%s/%s/%s\", githubDownload, tag, filename)\n\turls := []string{githubURL, giteeURL}\n\tif preferGitee {\n\t\turls = []string{giteeURL, githubURL}\n\t}\n\n\tvar data []byte\n\tvar lastErr error\n\tfor _, u := range urls {\n\t\tslog.Info(\"updater: downloading\", \"url\", u)\n\t\tdata, lastErr = downloadFile(u)\n\t\tif lastErr == nil {\n\t\t\tbreak\n\t\t}\n\t\tslog.Debug(\"updater: download failed, trying next\", \"error\", lastErr)\n\t}\n\tif lastErr != nil && data == nil {\n\t\treturn fmt.Errorf(\"download failed from all sources: %w\", lastErr)\n\t}\n\n\tvar binary []byte\n\tvar err error\n\tif goos == \"windows\" {\n\t\tbinary, err = extractBinaryFromZip(data)\n\t} else {\n\t\tbinary, err = extractBinaryFromTarGz(data)\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"extract binary: %w\", err)\n\t}\n\n\treturn replaceBinary(binary)\n}\n\nfunc downloadFile(url string) ([]byte, error) {\n\tclient := &http.Client{","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/updater.go#L137-L173","documentation":"SelfUpdate (core/updater.go:155) returns this when downloading the release archive failed from every configured download URL (GitHub and Gitee release assets). `lastErr` wraps the final download attempt's error (network failure, non-200 like 404 for a missing asset, redirect loop, timeout). No binary was downloaded, so the update is safely aborted before any file changes.","triggerScenarios":"Both `downloadFile` attempts fail: the release asset `cc-connect-<tag>-<goos>-<goarch>.tar.gz|.zip` does not exist (404 — wrong tag or missing platform build), the download times out (5-minute limit), a non-200 status is returned (error at line 195), a redirect loop hits the >10 limit (error 919), or both hosts are unreachable. Called by cmdUpgradeConfirm after the user confirms an upgrade.","commonSituations":"User confirms upgrade to a tag whose assets were never published for their OS/arch; GitHub release asset URLs broken after repo transfer; firewall blocking github.com release downloads (objects.githubusercontent.com); China networks failing to reach GitHub while Gitee mirror also lacks the asset; proxy misconfiguration.","solutions":["Read the wrapped error: 'HTTP 404' means the asset for your tag/OS/arch doesn't exist — verify the release page has `cc-connect-<tag>-<goos>-<goarch>` for your platform.","Check network reachability of the printed download URLs (`updater: downloading url=...` in the logs) with curl; if GitHub is blocked, retry with preferGitee=true.","Verify the tag passed to SelfUpdate exactly matches a published release tag (e.g. v1.2.3, with the `v` prefix).","Set HTTPS_PROXY if a corporate proxy is required, then retry the upgrade command.","If no release works, fall back to installing manually from the release page or via go install / package manager."],"exampleFix":"// before: error shows only the last source's failure\nreturn fmt.Errorf(\"download failed from all sources: %w\", lastErr)\n\n// after: report every attempted URL so users can test them directly\nreturn fmt.Errorf(\"download failed from all sources (%v): %w\", urls, lastErr)","handlingStrategy":"retry","validationCode":"func assetURLWorks(tag, goos, goarch string) error {\n\text := \".tar.gz\"\n\tif goos == \"windows\" {\n\t\text = \".zip\"\n\t}\n\tu := fmt.Sprintf(\"https://github.com/chenhg5/cc-connect/releases/download/%s/cc-connect-%s-%s-%s%s\", tag, tag, goos, goarch, ext)\n\tresp, err := http.Head(u)\n\tif err != nil {\n\t\treturn err\n\t}\n\tresp.Body.Close()\n\tif resp.StatusCode != 200 {\n\t\treturn fmt.Errorf(\"asset missing: HTTP %d for %s\", resp.StatusCode, u)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := core.SelfUpdate(tag, preferGitee); err != nil {\n\tif strings.Contains(err.Error(), \"download failed from all sources\") {\n\t\tslog.Error(\"upgrade aborted; no binary was modified\", \"err\", err)\n\t\t// safe to retry later or with the other mirror\n\t\treturn fmt.Errorf(\"upgrade aborted: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Confirm the target release publishes an asset for your exact GOOS/GOARCH before upgrading.","Use preferGitee=true in networks where GitHub release downloads are blocked.","Check the log line `updater: downloading url=...` and curl that URL to test reachability.","Configure HTTPS_PROXY for corporate networks; asset downloads go to a separate CDN host.","Retry on transient network failures — the updater already alternates GitHub/Gitee automatically."],"tags":["network","http","download","updater","release-assets"],"backgroundTag":"network-request-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}