{"record":{"id":"21b2ac0821841d2f","repo":"BoundaryML/baml","slug":"failed-to-download-library-0","errorCode":null,"errorMessage":"Failed to download library: {0}","messagePattern":"Failed to download library: (.+?)","errorType":"exception","errorClass":"BamlSysError","httpStatus":null,"severity":"error","filePath":"languages/rust/baml-sys/src/error.rs","lineNumber":45,"sourceCode":"    },\n\n    /// Version mismatch between Rust package and loaded library.\n    #[error(\"Version mismatch: Rust package expects {expected}, but library reports {actual}\")]\n    VersionMismatch { expected: String, actual: String },\n\n    /// Platform not supported.\n    #[error(\"Platform not supported: {os}/{arch}\")]\n    UnsupportedPlatform {\n        os: &'static str,\n        arch: &'static str,\n    },\n\n    /// Failed to determine cache directory.\n    #[error(\"Failed to determine cache directory: {0}\")]\n    CacheDir(String),\n\n    /// Download failed.\n    #[error(\"Failed to download library: {0}\")]\n    DownloadFailed(String),\n\n    /// Checksum mismatch after download.\n    #[error(\"Checksum mismatch: expected {expected}, got {actual}\")]\n    ChecksumMismatch { expected: String, actual: String },\n\n    /// IO error.\n    #[error(\"IO error: {0}\")]\n    Io(#[from] std::io::Error),\n\n    /// Library already initialized with different path.\n    #[error(\"Library already initialized from {existing_path}, cannot change to {requested_path}\")]\n    AlreadyInitialized {\n        existing_path: PathBuf,\n        requested_path: PathBuf,\n    },\n}\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/languages/rust/baml-sys/src/error.rs#L27-L63","documentation":"The BAML native shared library was not present in the cache, so baml-sys attempted to download it and the HTTP download failed. The wrapped string carries the underlying cause (network error, bad URL, non-success status, or failure to write the file). The library cannot load the native component until the download succeeds.","triggerScenarios":"First-time load/init with a cold cache when the network is down, the download URL is unreachable or returns non-200, a proxy blocks the request, or the response body cannot be written to disk.","commonSituations":"Air-gapped or firewalled CI runners, corporate proxies requiring auth, DNS failures, transient network flaps during first install, or a version whose artifact was removed from the server.","solutions":["Check network connectivity to the download host from the failing machine","Configure proxy environment variables (HTTPS_PROXY) if behind a corporate proxy","Retry after a transient network failure (the download will restart)","Pre-seed the cache directory with the library artifact so no download is needed","Verify the BAML version you requested actually has a published artifact"],"exampleFix":"// before\ncurl https://download-host/...  # fails behind proxy\n// after\nexport HTTPS_PROXY=http://proxy.corp:8080","handlingStrategy":"retry","validationCode":"let url = download_url();\nlet reachable = std::net::TcpStream::connect((host_of(&url), 443)).is_ok();\nif !reachable {\n    eprintln!(\"download host unreachable; check network/proxy before init\");\n}","typeGuard":"fn is_transient_network_err(msg: &str) -> bool {\n    msg.contains(\"timed out\") || msg.contains(\"connection\") || msg.contains(\"resolve\")\n}","tryCatchPattern":"match baml_sys::init() {\n    Err(BamlSysError::DownloadFailed(msg)) if is_transient_network_err(&msg) => {\n        // exponential backoff retry, then fail\n    }\n    Err(BamlSysError::DownloadFailed(msg)) => {\n        eprintln!(\"download failed permanently: {msg}; pre-seed cache\");\n    }\n    other => other.map(|_| ())?,\n}","preventionTips":["Pre-seed the cache directory with the library in Docker images to avoid runtime downloads","Configure HTTPS_PROXY/NO_PROXY correctly in CI","Pin BAML versions known to have published artifacts","Add retry with backoff around first-time initialization"],"tags":["rust","network","download","native-library"],"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-14T05:17:10.506Z"}