{"record":{"id":"46367418bc3e095e","repo":"BoundaryML/baml","slug":"errdownloadfailed","errorCode":"ErrDownloadFailed","errorMessage":"baml: failed to download shared library","messagePattern":"baml: failed to download shared library","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/lib_common.go","lineNumber":82,"sourceCode":"\t\tTimeout:   5 * time.Minute,\n\t}\n}\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","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/lib_common.go#L64-L100","documentation":"ErrDownloadFailed is the sentinel for any failure while downloading the BAML native shared library: constructing the HTTP GET request, executing it (network/DNS/TLS errors), or receiving a non-success HTTP status. downloadBamlLibrary wraps all of these with %w so errors.Is(err, ErrDownloadFailed) matches.","triggerScenarios":"downloadBamlLibrary: http.NewRequest fails (malformed download URL), httpClient.Do returns a network error (lib_common.go:494/504), or the response status is not 200.","commonSituations":"Air-gapped or firewalled CI with no egress to the BAML release host; corporate proxy requiring auth; DNS failures in containers; GitHub/release CDN outage; rate limiting from repeated downloads.","solutions":["Check network egress / proxy settings; set HTTPS_PROXY if the environment requires it","Pre-download the library once and place it in the cache directory so no runtime download is needed","Read the wrapped message for the URL and underlying net/http error; test the URL with curl","Vendor the library into your artifact (or use a build step) to remove the runtime download dependency"],"exampleFix":"// before\n// air-gapped CI: download fails at runtime\n// after (CI step)\nRUN curl -fL -o /root/.cache/baml/libbaml.so <pinned-release-url> && echo \"$SHA256  /root/.cache/baml/libbaml.so\" | sha256sum -c -","handlingStrategy":"fallback","validationCode":"conn, err := net.DialTimeout(\"tcp\", \"github.com:443\", 3*time.Second)\nif err != nil {\n    return fmt.Errorf(\"no egress for baml library download: %w\", err)\n}\nconn.Close()","typeGuard":null,"tryCatchPattern":"if errors.Is(err, baml.ErrDownloadFailed) {\n    // use pre-vendored library from image, or retry with backoff\n    return loadVendoredLibrary()\n}","preventionTips":["Pre-download the library in your Dockerfile so runtime downloads never happen","Configure HTTPS_PROXY correctly in restricted networks","Add a liveness check that the library URL is reachable before deployment"],"tags":["network","download","http"],"backgroundTag":"http-request-failed","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"}