abiosoft/colima · error

error parsing SHA file from '%s': %w

Error message

error parsing SHA file from '%s': %w

What it means

The checksum file downloaded fine but parseSHAContent failed while scanning it. The input is an in-memory []byte, so genuine read errors are essentially impossible — the realistic trigger is bufio.Scanner's ErrTooLong: a single line exceeding the default 64KB buffer. In practice the body is not a checksum file at all (binary payload or garbage served with a 200).

Source

Thrown at util/downloader/sha.go:113

}

// fetchSHAFromURL fetches SHA checksum file and extracts digest for the target file
func fetchSHAFromURL(shaURL, targetFilename string) (string, error) {
	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
	defer cancel()

	client := NewHTTPClient()

	// fetch SHA file content
	data, err := client.Fetch(ctx, shaURL)
	if err != nil {
		return "", fmt.Errorf("error downloading SHA file from '%s': %w", shaURL, err)
	}

	// parse SHA file to find the matching entry
	digest, err := parseSHAContent(data, targetFilename)
	if err != nil {
		return "", fmt.Errorf("error parsing SHA file from '%s': %w", shaURL, err)
	}

	return digest, nil
}

// parseSHAContent reads SHA checksum content and extracts the digest for the target filename.
// Supports formats:
//   - GNU coreutils: "<hash>  <filename>" (two spaces)
//   - BSD/binary mode: "<hash> *<filename>" (space + asterisk)
func parseSHAContent(data []byte, targetFilename string) (string, error) {
	scanner := bufio.NewScanner(bytes.NewReader(data))
	for scanner.Scan() {
		line := scanner.Text()
		// format: "<hash>  <filename>" (two spaces) or "<hash> *<filename>" (binary mode)
		parts := strings.Fields(line)
		if len(parts) >= 2 {
			hash := parts[0]
			filename := strings.TrimPrefix(parts[len(parts)-1], "*")

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. curl the sha URL and inspect what the body actually contains
  2. Fix the URL or the upstream content so a real checksum file is served
  3. If it is a captive portal, fix network connectivity and retry
Defensive patterns

Strategy: try-catch

Try / catch

cacheFile, err := downloader.Download(host, req)
if err != nil && strings.Contains(err.Error(), "error parsing SHA file") {
    // body is not a checksum file: fetch it yourself and inspect
    // curl -fsSL "$SHA_URL" | head
    return fmt.Errorf("checksum url %q does not serve a parseable checksum file: %w", req.SHA.URL, err)
}

Prevention

When it happens

Trigger: Server returns binary data or one over-long line with HTTP 200 (misconfigured mirror, captive-portal/HTML page behind a 200, error blob); pathological checksum files with >64KB lines.

Common situations: CDN serving an HTML page with status 200 instead of the checksum file; checksum endpoints returning concatenated or binary data.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/425c1468dc6aa884. Report an issue: GitHub.