{"record":{"id":"b52d2d7c35eb76e3","repo":"Hmbown/CodeWhale","slug":"failed-to-build-http-client-b52d2d","errorCode":null,"errorMessage":"Failed to build HTTP client","messagePattern":"Failed to build HTTP client","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/tui/src/vision/tools.rs","lineNumber":39,"sourceCode":"    route_client: Option<CodewhaleClient>,\n}\n\nimpl ImageAnalyzeTool {\n    #[cfg(test)]\n    #[must_use]\n    pub fn new(config: VisionModelConfig) -> Self {\n        Self::new_with_route_client(config, None)\n    }\n\n    #[must_use]\n    pub fn new_with_route_client(\n        config: VisionModelConfig,\n        route_client: Option<CodewhaleClient>,\n    ) -> Self {\n        let client = crate::tls::reqwest_client_builder()\n            .timeout(Duration::from_secs(120))\n            .build()\n            .expect(\"Failed to build HTTP client\");\n        Self {\n            config,\n            client,\n            route_client,\n        }\n    }\n\n    async fn read_image_file(path: &Path) -> Result<(String, String), ToolError> {\n        let bytes = tokio::fs::read(path)\n            .await\n            .map_err(|e| ToolError::execution_failed(format!(\"Failed to read image file: {e}\")))?;\n\n        let mime_type = Self::detect_mime_type(path)?;\n        let base64_data = BASE64.encode(&bytes);\n        Ok((base64_data, mime_type))\n    }\n\n    fn resolve_image_path(workspace: &Path, image_path: &str) -> Result<PathBuf, ToolError> {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/vision/tools.rs#L21-L57","documentation":"Panic from `.expect(\"Failed to build HTTP client\")` on `reqwest::ClientBuilder::build()` in `VisionTools::new_with_route_client` (crates/tui/src/vision/tools.rs:39). The builder applies a 120s timeout and the crate TLS settings (`crate::tls::reqwest_client_builder`); `build()` fails only when reqwest cannot initialize its underlying connector/TLS backend, which is treated as a hard startup error for vision tooling.","triggerScenarios":"Calling `new_with_route_client` in a binary that links an incompatible or disabled TLS backend (rustls with no crypto provider installed, or a broken native-tls/openssl), or in environments where reqwest's resolver/socket initialization fails (e.g. blocked system resolver on exotic targets).","commonSituations":"Statically linked or musl builds missing TLS crypto init; running before `install_crypto_provider()` is called for rustls (see `install_crypto_provider` used in app-server tests); embedding the TUI crate in another binary with a different reqwest feature set.","solutions":["Ensure the TLS crypto provider is installed at startup: call the crate's `install_crypto_provider()` equivalent before constructing vision tools.","Check Cargo feature flags for reqwest/rustls consistency between the TUI crate and the embedding binary.","Reproduce in a minimal binary calling `crate::tls::reqwest_client_builder().build()` and inspect the returned io/error to identify the backend issue.","If a caller cannot tolerate a panic, switch to a fallible constructor returning Result and surface the message instead of expect."],"exampleFix":"// before\nlet client = crate::tls::reqwest_client_builder().timeout(Duration::from_secs(120)).build().expect(\"Failed to build HTTP client\");\n// after\ninstall_crypto_provider();\nlet client = crate::tls::reqwest_client_builder().timeout(Duration::from_secs(120)).build().expect(\"Failed to build HTTP client (TLS backend init failed)\");","handlingStrategy":"validation","validationCode":"// at process startup, before any reqwest client is built\ninstall_crypto_provider(); // installs rustls ring/aws-lc provider where needed","typeGuard":null,"tryCatchPattern":"let client = crate::tls::reqwest_client_builder()\n    .timeout(Duration::from_secs(120))\n    .build()\n    .with_context(\"Failed to build HTTP client\")?; // or expect with context at call sites that cannot fail gracefully","preventionTips":["Install the TLS crypto provider once at binary startup.","Keep reqwest/rustls feature flags consistent across the workspace and embedders.","Smoke-test client construction in a startup health check so failures appear before tool use."],"tags":["http","reqwest","tls","panic","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}