{"record":{"id":"e9c6d08c5b0a68c1","repo":"charmbracelet/glow","slug":"unable-to-get-url-w","errorCode":null,"errorMessage":"unable to get url: %w","messagePattern":"unable to get url: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"github.go","lineNumber":30,"sourceCode":"\n// findGitHubREADME tries to find the correct README filename in a repository using GitHub API.\nfunc findGitHubREADME(u *url.URL) (*source, error) {\n\towner, repo, ok := strings.Cut(strings.TrimPrefix(u.Path, \"/\"), \"/\")\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"invalid url: %s\", u.String())\n\t}\n\n\ttype readme struct {\n\t\tDownloadURL string `json:\"download_url\"`\n\t}\n\n\tapiURL := fmt.Sprintf(\"https://api.%s/repos/%s/%s/readme\", u.Hostname(), owner, repo)\n\n\t//nolint:bodyclose\n\t// it is closed on the caller\n\tres, err := http.Get(apiURL) //nolint: gosec,noctx\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get url: %w\", err)\n\t}\n\n\tbody, err := io.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to read http response body: %w\", err)\n\t}\n\n\tvar result readme\n\tif err := json.Unmarshal(body, &result); err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to parse json: %w\", err)\n\t}\n\n\tif res.StatusCode == http.StatusOK {\n\t\t//nolint:bodyclose\n\t\t// it is closed on the caller\n\t\tresp, err := http.Get(result.DownloadURL) //nolint: noctx\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to get url: %w\", err)","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/github.go#L12-L48","documentation":"This wraps the failure of http.Get(apiURL) where apiURL is https://api.{hostname}/repos/{owner}/{repo}/readme. The error is a *url.Error from net/http: DNS resolution failure, connection refused/timeout, TLS handshake error, or proxy failure. Nothing was received from the API, so no status code exists yet.","triggerScenarios":"No network or DNS failure resolving api.github.com; HTTPS_PROXY/HTTP_PROXY pointing at a dead proxy; TLS interception with an untrusted CA (corporate MITM) failing verification; firewall dropping outbound 443; IPv6-only misconfiguration causing dial timeouts.","commonSituations":"Airports/captive portals; corporate proxies with expired certs; containers without CA certificates (update-ca-certificates); sandboxes that block egress (must allow api.github.com:443).","solutions":["Test reachability: curl -v https://api.github.com/repos/OWNER/REPO/readme","Check proxy env: env | grep -i proxy and fix or unset HTTPS_PROXY","Install/refresh the system CA bundle if TLS verification fails","Allow egress to api.github.com:443 in firewall/sandbox rules, or run glow offline on local files"],"exampleFix":"# before\nglow https://github.com/owner/repo\n# Error: unable to get url: Get \"https://api.github.com/...\": proxyconnect tcp: connection refused\n\n# after\n$ unset HTTPS_PROXY http_proxy && glow https://github.com/owner/repo","handlingStrategy":"retry","validationCode":"// cheap liveness probe before handing the URL to glow\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\ndefer cancel()\nreq, _ := http.NewRequestWithContext(ctx, http.MethodHead, \"https://api.github.com\", nil)\nif _, err := http.DefaultClient.Do(req); err != nil {\n\treturn fmt.Errorf(\"api.github.com unreachable (check network/proxy): %w\", err)\n}","typeGuard":null,"tryCatchPattern":"var src *source\nerr := retry(3, 500*time.Millisecond, func() error {\n\tvar err error\n\tsrc, err = findGitHubREADME(u)\n\tif err != nil && strings.Contains(err.Error(), \"unable to get url\") {\n\t\tvar ue *url.Error\n\t\tif errors.As(err, &ue) && (errors.Is(ue, context.DeadlineExceeded) || ue.Timeout() || errors.Is(ue, syscall.ECONNREFUSED)) {\n\t\t\treturn err // transient transport failure: retry\n\t\t}\n\t}\n\treturn err // anything else: stop\n})\n\nfunc retry(n int, d time.Duration, fn func() error) error {\n\tvar err error\n\tfor i := 0; i < n; i++ {\n\t\tif err = fn(); err == nil {\n\t\t\treturn nil\n\t\t}\n\t\ttime.Sleep(d << i)\n\t}\n\treturn err\n}","preventionTips":["Verify egress to api.github.com:443 from firewalled environments before scripting glow against GitHub URLs","Set correct HTTPS_PROXY and install the proxy CA bundle so TLS interception succeeds","Keep a local clone fallback so network loss never blocks rendering"],"tags":["network","http","dns","proxy","tls","github"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}