{"record":{"id":"d684886b96c81751","repo":"Kuberwastaken/claurst","slug":"failed-to-build-reqwest-client-d68488","errorCode":null,"errorMessage":"Failed to build reqwest client","messagePattern":"Failed to build reqwest client","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src-rust/crates/bridge/src/lib.rs","lineNumber":411,"sourceCode":"    state: Arc<RwLock<BridgeState>>,\r\n    http: reqwest::Client,\r\n    reconnect_count: u32,\r\n    #[allow(dead_code)]\r\n    last_ping: Option<std::time::Instant>,\r\n}\r\n\r\nimpl BridgeSession {\r\n    /// Create a new bridge session; generates a fresh UUID for `session_id`.\r\n    pub fn new(config: BridgeConfig) -> Self {\r\n        let session_id = uuid::Uuid::new_v4().to_string();\r\n        let http = reqwest::Client::builder()\r\n            .timeout(std::time::Duration::from_secs(30))\r\n            .user_agent(format!(\r\n                \"claude-code-rust/{}\",\r\n                env!(\"CARGO_PKG_VERSION\")\r\n            ))\r\n            .build()\r\n            .expect(\"Failed to build reqwest client\");\r\n\r\n        Self {\r\n            config,\r\n            session_id,\r\n            state: Arc::new(RwLock::new(BridgeState::Connecting)),\r\n            http,\r\n            reconnect_count: 0,\r\n            last_ping: None,\r\n        }\r\n    }\r\n\r\n    pub fn session_id(&self) -> &str {\r\n        &self.session_id\r\n    }\r\n\r\n    pub fn current_state(&self) -> BridgeState {\r\n        self.state.read().clone()\r\n    }\r","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/bridge/src/lib.rs#L393-L429","documentation":"This panic comes from an `.expect()` on `reqwest::Client::builder().build()` when constructing the bridge's HTTP client (30s timeout, claude-code-rust user agent). The builder only fails on process-wide initialization problems, essentially always TLS backend setup, so the code treats it as unrecoverable during `Bridge::new`.","triggerScenarios":"Calling `Bridge::new(config, session_id)` in a process where reqwest cannot initialize its TLS backend — e.g. missing native TLS library or rustls crypto provider conflict.","commonSituations":"Minimal Linux containers without libssl or CA certs; statically-linked musl builds missing TLS pieces; environments where another component already installed a different ring/aws-lc crypto provider for rustls.","solutions":["Verify TLS linkage: run `ldd` on the binary and install the missing `libssl`/crypto library, or build with reqwest's `rustls-tls` feature instead of native-tls.","Install CA certificates in the deployment image (`ca-certificates` package).","Check for conflicting `CryptoProvider` initializers if using rustls 0.23+ (only one process-wide provider may be installed).","Make `Bridge::new` return `Result` and propagate the `reqwest::Error` with context rather than panicking."],"exampleFix":"// before\n.build()\n.expect(\"Failed to build reqwest client\");\n// after\n.build()\n.map_err(|e| BridgeError::Init(format!(\"Failed to build reqwest client: {e}\")))?;","handlingStrategy":"fallback","validationCode":"// Startup probe before creating the Bridge:\nfn http_stack_ok() -> bool {\n    reqwest::Client::builder()\n        .timeout(std::time::Duration::from_secs(1))\n        .build()\n        .is_ok()\n}","typeGuard":null,"tryCatchPattern":"// Panic, not Result — isolate construction:\nlet bridge = std::panic::catch_unwind(|| Bridge::new(config, session_id))\n    .map_err(|_| anyhow::anyhow!(\"bridge init failed: cannot build HTTP client (TLS backend?)\"))?;","preventionTips":["Prefer rustls over native-tls in Cargo features for portable binaries","Verify CA certificates and libssl exist in the target container","Check for conflicting rustls CryptoProvider installs when linking other crates","Probe HTTP client construction once during startup and fail fast with a clear message"],"tags":["rust","reqwest","tls","panic","bridge"],"backgroundTag":"http-client-init-failed","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}