{"record":{"id":"5ad270185ca63fd2","repo":"BoundaryML/baml","slug":"error-reading-checksum-body-s-w","errorCode":null,"errorMessage":"error reading checksum body %s: %w","messagePattern":"error reading checksum body (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/lib_common.go","lineNumber":594,"sourceCode":"\thttpClient := uninstrumentedHTTPClient()\n\t//orchestrion:ignore\n\tresp, err := httpClient.Get(checksumURL)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"network error fetching checksum %s: %w\", checksumURL, err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode == http.StatusNotFound {\n\t\tlogger.Debug(\"Checksum file not found (404)\", \"url\", checksumURL)\n\t\treturn \"\", fmt.Errorf(\"checksum file not found (404)\")\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"unexpected status %d fetching checksum %s\", resp.StatusCode, checksumURL)\n\t}\n\n\tbodyBytes, err := io.ReadAll(io.LimitReader(resp.Body, 4096))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error reading checksum body %s: %w\", checksumURL, err)\n\t}\n\n\tlines := strings.Split(string(bodyBytes), \"\\n\")\n\tfor _, line := range lines {\n\t\tparts := strings.Fields(line)\n\t\tif len(parts) >= 2 {\n\t\t\tchecksum, filenameInLine := parts[0], strings.TrimPrefix(parts[1], \"*\")\n\t\t\tif filenameInLine == targetFilename {\n\t\t\t\tif len(checksum) == 64 && isHex(checksum) {\n\t\t\t\t\tlogger.Debug(\"Found matching checksum in file\", \"filename\", targetFilename, \"checksum\", checksum)\n\t\t\t\t\treturn checksum, nil\n\t\t\t\t}\n\t\t\t\tlogger.Warn(\"Invalid checksum format found in checksum file\",\n\t\t\t\t\t\"url\", checksumURL,\n\t\t\t\t\t\"filename\", targetFilename,\n\t\t\t\t\t\"found_checksum\", checksum)\n\t\t\t\treturn \"\", fmt.Errorf(\"invalid checksum format '%s' for %s in %s\", checksum, targetFilename, checksumURL)\n\t\t\t}","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/lib_common.go#L576-L612","documentation":"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.","triggerScenarios":"io.ReadAll(io.LimitReader(resp.Body, 4096)) returns an error: connection dropped while reading the body, or a proxy terminated the response early.","commonSituations":"Flaky corporate proxies, CI network instability, or server closing connections under load.","solutions":["Retry the checksum download; this is typically transient","Increase HTTP client timeouts if slow networks truncate bodies","Check proxy stability between client and artifact host","Fall back gracefully — the caller proceeds with checksum verification skipped"],"exampleFix":"// before: single attempt\nbody, err := downloadChecksum(url, name)\n// after: retry transient body-read failures\nvar body string\nvar err error\nfor i := 0; i < 3 && err != nil; i++ {\n    body, err = downloadChecksum(url, name)\n    time.Sleep(time.Duration(i+1) * time.Second)\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"body, err := downloadChecksum(url, name)\nif err != nil && strings.Contains(err.Error(), \"error reading checksum body\") {\n    // transient IO failure: retry with backoff\n}","preventionTips":["Retry body-read failures; they are usually transient network drops","Increase client timeouts on slow networks","Avoid flaky proxies for artifact downloads in CI","Keep checksum files small (they are capped at 4KB anyway)"],"tags":["network","http","io","checksum"],"backgroundTag":"network-request-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}