lima-vm/lima · error

failed to read %#q content: %w

Error message

failed to read %#q content: %w

What it means

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.

Source

Thrown at pkg/limatmpl/github.go:174

	}
	defer resp.Body.Close()

	// Special rule for branch/tag propagation for github:ORG// requests.
	if resp.StatusCode == http.StatusNotFound && repo == org {
		defaultBranch, err := getGitHubDefaultBranch(ctx, org, repo)
		if err == nil {
			return resolveGitHubRedirect(ctx, org, repo, defaultBranch, filePath, branch)
		}
	}
	if resp.StatusCode != http.StatusOK {
		return "", fmt.Errorf("file %#q not found or inaccessible: status %d", resp.Request.URL, resp.StatusCode)
	}

	// Read first 1KB to check the file content
	buf := make([]byte, 1024)
	n, err := resp.Body.Read(buf)
	if err != nil && !errors.Is(err, io.EOF) {
		return "", fmt.Errorf("failed to read %#q content: %w", resp.Request.URL, err)
	}
	content := string(buf[:n])

	// Symlink can also be a github: redirect if we are in a github:ORG// repo.
	if repo == org && strings.HasPrefix(content, "github:") {
		return validateGitHubRedirect(content, org, origBranch, resp.Request.URL.String())
	}

	// A symlink must be a single line (without trailing newline), no spaces, no colons
	if !(content == "" || strings.ContainsAny(content, "\n :")) {
		// symlink is relative to the directory of filePath, and must stay within the repo
		filePath, err = symlinkTarget(filePath, content)
		if err != nil {
			return "", err
		}
	}
	return githubUserContentURL(org, repo, branch, filePath), nil
}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Retry the command — this is usually a transient network interruption
  2. Test stability with `curl -O <the URL from the error>` and compare sizes
  3. Disable or bypass intercepting proxies/VPN that may truncate responses
  4. Check for MTU issues on VPN links if it reproduces consistently
Defensive patterns

Strategy: retry

Try / catch

url, err := transformGitHubURL(ctx, ref)
if err != nil && strings.Contains(err.Error(), "failed to read") {
    // transient mid-stream error; retry with backoff
    for i := 0; i < 3 && err != nil; i++ {
        time.Sleep(time.Duration(1<<i) * time.Second)
        url, err = transformGitHubURL(ctx, ref)
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/11bf93004798af82. Report an issue: GitHub.