{"record":{"id":"2c206b38bdbd6f50","repo":"BoundaryML/baml","slug":"errchecksummismatch","errorCode":"ErrChecksumMismatch","errorMessage":"baml: downloaded library checksum mismatch","messagePattern":"baml: downloaded library checksum mismatch","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/lib_common.go","lineNumber":84,"sourceCode":"}\n\n// setOrchestrionInternalFlag tries to set DD__tracer_internal=true using reflection.\n// This field is added by Orchestrion's code transformation.\nfunc setOrchestrionInternalFlag(transport *http.Transport) {\n\t// Use reflection to set the field if it exists\n\tval := reflect.ValueOf(transport).Elem()\n\tfield := val.FieldByName(\"DD__tracer_internal\")\n\tif field.IsValid() && field.CanSet() && field.Kind() == reflect.Bool {\n\t\tfield.SetBool(true)\n\t}\n}\n\nvar (\n\tErrLoadLibrary          = errors.New(\"baml: failed loading shared library\")\n\tErrNotSupportedPlatform = errors.New(\"baml: platform not supported (only Linux and MacOS amd64/arm64)\")\n\tErrDownloadFailed       = errors.New(\"baml: failed to download shared library\")\n\tErrCacheDir             = errors.New(\"baml: failed to determine or create cache directory\")\n\tErrChecksumMismatch     = errors.New(\"baml: downloaded library checksum mismatch\")\n\tErrVersionMismatch      = errors.New(\"baml: library version mismatch\")\n\tErrInitialization       = errors.New(\"baml: initialization failed\")\n)\n\nvar (\n\tbamlSharedLibraryPath = \"\"\n\tinitErr               error\n\tinitOnce              sync.Once\n\tbamlLibHandle         unsafe.Pointer\n\tlogger                *slog.Logger\n)\n\nfunc SetSharedLibraryPath(path string) {\n\tif bamlLibHandle != nil {\n\t\tlogger.Warn(\"SetSharedLibraryPath called after BAML library was initialized. Path ignored.\", \"path\", path)\n\t\treturn\n\t}\n\tbamlSharedLibraryPath = path","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/lib_common.go#L66-L102","documentation":"ErrChecksumMismatch is returned by downloadBamlLibrary when the SHA-256 of the downloaded native library does not match the pinned expected checksum. This guard exists so a corrupt or tampered download is never loaded or executed. The error names the file, expected and actual checksums.","triggerScenarios":"downloadBamlLibrary at lib_common.go:544: actualChecksum != expectedChecksum after hashing the downloaded temp file for the target platform filename.","commonSituations":"Interrupted/proxied downloads producing truncated files; corporate TLS-inspection proxies modifying payloads; CDN serving a stale artifact after a release; MITM tampering (the case the check defends against).","solutions":["Delete the cached/temp file and re-download — a single corrupted transfer is the most common cause","Verify your network path: bypass suspicious proxies or retry from a different network","Confirm the Go client VERSION matches a released library artifact; a stale pinned checksum vs newer artifact indicates a version skew","If it persists, check the release infrastructure/checksum manifest and report upstream"],"exampleFix":"// before\n// flaky proxy truncated the download once; lib cached corrupt\n// after\nrm -rf \"$HOME/.cache/baml\" && go run .  // forces clean re-download and checksum verification","handlingStrategy":"retry","validationCode":"sum, err := computeSha256(tmpFile)\nif err != nil || sum == \"\" {\n    return fmt.Errorf(\"download produced empty/corrupt file\")\n}","typeGuard":null,"tryCatchPattern":"if errors.Is(err, baml.ErrChecksumMismatch) {\n    os.Remove(cachedLib)\n    return retryDownload(3, time.Second) // clean re-download with backoff\n}","preventionTips":["Delete cached library files when checksum errors appear — never force-load an unverified file","Avoid TLS-intercepting proxies for release-artifact hosts","Keep client VERSION and release artifacts aligned so pinned checksums are valid"],"tags":["security","download","checksum"],"backgroundTag":"checksum-mismatch","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}