BoundaryML/baml · error

error reading checksum body %s: %w

Error message

error reading checksum body %s: %w

What it means

After a 200 response, the checksum body is read (capped at 4KB). This error wraps an io.ReadAll failure, meaning the response body could not be fully read — usually a connection reset or timeout mid-body.

Source

Thrown at engine/language_client_go/baml_go/lib_common.go:594

	httpClient := uninstrumentedHTTPClient()
	//orchestrion:ignore
	resp, err := httpClient.Get(checksumURL)
	if err != nil {
		return "", fmt.Errorf("network error fetching checksum %s: %w", checksumURL, err)
	}
	defer resp.Body.Close()

	if resp.StatusCode == http.StatusNotFound {
		logger.Debug("Checksum file not found (404)", "url", checksumURL)
		return "", fmt.Errorf("checksum file not found (404)")
	}
	if resp.StatusCode != http.StatusOK {
		return "", fmt.Errorf("unexpected status %d fetching checksum %s", resp.StatusCode, checksumURL)
	}

	bodyBytes, err := io.ReadAll(io.LimitReader(resp.Body, 4096))
	if err != nil {
		return "", fmt.Errorf("error reading checksum body %s: %w", checksumURL, err)
	}

	lines := strings.Split(string(bodyBytes), "\n")
	for _, line := range lines {
		parts := strings.Fields(line)
		if len(parts) >= 2 {
			checksum, filenameInLine := parts[0], strings.TrimPrefix(parts[1], "*")
			if filenameInLine == targetFilename {
				if len(checksum) == 64 && isHex(checksum) {
					logger.Debug("Found matching checksum in file", "filename", targetFilename, "checksum", checksum)
					return checksum, nil
				}
				logger.Warn("Invalid checksum format found in checksum file",
					"url", checksumURL,
					"filename", targetFilename,
					"found_checksum", checksum)
				return "", fmt.Errorf("invalid checksum format '%s' for %s in %s", checksum, targetFilename, checksumURL)
			}

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Retry the checksum download; this is typically transient
  2. Increase HTTP client timeouts if slow networks truncate bodies
  3. Check proxy stability between client and artifact host
  4. Fall back gracefully — the caller proceeds with checksum verification skipped

Example fix

// before: single attempt
body, err := downloadChecksum(url, name)
// after: retry transient body-read failures
var body string
var err error
for i := 0; i < 3 && err != nil; i++ {
    body, err = downloadChecksum(url, name)
    time.Sleep(time.Duration(i+1) * time.Second)
}
Defensive patterns

Strategy: retry

Try / catch

body, err := downloadChecksum(url, name)
if err != nil && strings.Contains(err.Error(), "error reading checksum body") {
    // transient IO failure: retry with backoff
}

Prevention

When it happens

Trigger: io.ReadAll(io.LimitReader(resp.Body, 4096)) returns an error: connection dropped while reading the body, or a proxy terminated the response early.

Common situations: Flaky corporate proxies, CI network instability, or server closing connections under load.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/5ad270185ca63fd2. Report an issue: GitHub.