{"record":{"id":"11bf93004798af82","repo":"lima-vm/lima","slug":"failed-to-read-q-content-w","errorCode":null,"errorMessage":"failed to read %#q content: %w","messagePattern":"failed to read %#q content: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limatmpl/github.go","lineNumber":174,"sourceCode":"\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) {\n\t\treturn \"\", fmt.Errorf(\"failed to read %#q content: %w\", resp.Request.URL, err)\n\t}\n\tcontent := string(buf[:n])\n\n\t// Symlink can also be a github: redirect if we are in a github:ORG// repo.\n\tif repo == org && strings.HasPrefix(content, \"github:\") {\n\t\treturn validateGitHubRedirect(content, org, origBranch, resp.Request.URL.String())\n\t}\n\n\t// A symlink must be a single line (without trailing newline), no spaces, no colons\n\tif !(content == \"\" || strings.ContainsAny(content, \"\\n :\")) {\n\t\t// symlink is relative to the directory of filePath, and must stay within the repo\n\t\tfilePath, err = symlinkTarget(filePath, content)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\treturn githubUserContentURL(org, repo, branch, filePath), nil\n}","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limatmpl/github.go#L156-L192","documentation":"When reading the first 1KB of the fetched file to probe for symlink content, a read error other than io.EOF aborts with \"failed to read <url> content: %w\". This indicates the response body could not be read — usually a truncated or interrupted connection mid-response.","triggerScenarios":"resolveGitHubSymlink calls resp.Body.Read on a 200 response and receives a non-EOF error: connection reset during body transfer, TLS handshake failure mid-stream, unexpected EOF from a truncated response, or decompression errors.","commonSituations":"Flaky networks or mobile connections dropping mid-transfer; proxies that truncate large responses; CDN edge failures on raw.githubusercontent.com; VPN disconnects during the fetch.","solutions":["Retry the command — this is usually a transient network interruption","Test stability with `curl -O <the URL from the error>` and compare sizes","Disable or bypass intercepting proxies/VPN that may truncate responses","Check for MTU issues on VPN links if it reproduces consistently"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"url, err := transformGitHubURL(ctx, ref)\nif err != nil && strings.Contains(err.Error(), \"failed to read\") {\n    // transient mid-stream error; retry with backoff\n    for i := 0; i < 3 && err != nil; i++ {\n        time.Sleep(time.Duration(1<<i) * time.Second)\n        url, err = transformGitHubURL(ctx, ref)\n    }\n}","preventionTips":["Retry on transient read failures with exponential backoff","Avoid flaky VPN/mobile networks during provisioning","Bypass TLS-intercepting proxies that truncate streams","Run `curl -O <url>` to test stream stability first"],"tags":["network","io","http"],"backgroundTag":"response-body-read-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}