{"record":{"id":"575ee0e531e66e96","repo":"lima-vm/lima","slug":"failed-to-fetch-file-w","errorCode":null,"errorMessage":"failed to fetch file: %w","messagePattern":"failed to fetch file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limatmpl/github.go","lineNumber":155,"sourceCode":"\tvar repoData struct {\n\t\tDefaultBranch string `json:\"default_branch\"`\n\t}\n\tif err := json.Unmarshal(body, &repoData); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to parse GitHub API response: %w\", err)\n\t}\n\tif repoData.DefaultBranch == \"\" {\n\t\treturn \"\", fmt.Errorf(\"repository %s/%s has no default branch\", org, repo)\n\t}\n\treturn repoData.DefaultBranch, nil\n}\n\n// resolveGitHubSymlink checks if a file at the given path is a symlink/redirect to another file.\n// If the file contains a single line without newline, space, or colon then it's treated as a path to the actual file.\n// Returns a URL to the redirect path if found, or a URL for original path otherwise.\nfunc resolveGitHubSymlink(ctx context.Context, org, repo, branch, filePath, origBranch string) (string, error) {\n\tresp, err := getGitHubUserContent(ctx, org, repo, branch, filePath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to fetch file: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\t// Special rule for branch/tag propagation for github:ORG// requests.\n\tif resp.StatusCode == http.StatusNotFound && repo == org {\n\t\tdefaultBranch, err := getGitHubDefaultBranch(ctx, org, repo)\n\t\tif err == nil {\n\t\t\treturn resolveGitHubRedirect(ctx, org, repo, defaultBranch, filePath, branch)\n\t\t}\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"file %#q not found or inaccessible: status %d\", resp.Request.URL, resp.StatusCode)\n\t}\n\n\t// Read first 1KB to check the file content\n\tbuf := make([]byte, 1024)\n\tn, err := resp.Body.Read(buf)\n\tif err != nil && !errors.Is(err, io.EOF) {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limatmpl/github.go#L137-L173","documentation":"resolveGitHubSymlink fetches the candidate .yaml file via getGitHubUserContent (raw.githubusercontent.com). If the HTTP request itself fails at the transport level (DNS failure, connection refused, TLS error, context cancellation), the error is wrapped as \"failed to fetch file: %w\". This is a network/transport failure, not an HTTP status problem.","triggerScenarios":"transformGitHubURL -> resolveGitHubSymlink -> getGitHubUserContent where http.DefaultClient.Do returns a non-nil error: no network connectivity, DNS resolution failure for raw.githubusercontent.com, blocked egress, expired TLS, or the caller's context being cancelled.","commonSituations":"Running limactl offline or behind a corporate proxy without HTTP_PROXY configured; firewall blocking raw.githubusercontent.com; IPv6 misconfiguration; context deadline exceeded on slow networks.","solutions":["Check basic connectivity: `curl -I https://raw.githubusercontent.com`","Configure proxy environment variables (HTTPS_PROXY/HTTP_PROXY) if behind a corporate firewall","Retry the command; transient DNS or connection failures often resolve","If the context was cancelled, increase the timeout or rerun without interruption"],"exampleFix":"// before\nexport HTTPS_PROXY=\n// after\nexport HTTPS_PROXY=http://proxy.corp.example:3128","handlingStrategy":"retry","validationCode":"// preflight connectivity check\nif _, err := http.Get(\"https://raw.githubusercontent.com\"); err != nil {\n    return fmt.Errorf(\"cannot reach raw.githubusercontent.com: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"url, err := transformGitHubURL(ctx, ref)\nif err != nil && strings.Contains(err.Error(), \"failed to fetch file\") {\n    // retry with backoff\n    for i := 0; i < 3; i++ {\n        time.Sleep(time.Duration(1<<i) * time.Second)\n        if url, err = transformGitHubURL(ctx, ref); err == nil { break }\n    }\n}","preventionTips":["Configure HTTPS_PROXY/HTTP_PROXY before running behind corporate firewalls","Allowlist raw.githubusercontent.com in egress rules","Prefer wired/stable networks for VM provisioning","Check DNS resolution of raw.githubusercontent.com first"],"tags":["network","http","github"],"backgroundTag":"http-request-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}