{"record":{"id":"51d42c9a7fab9b59","repo":"spacedriveapp/spacedrive","slug":"failed-to-create-http-client","errorCode":null,"errorMessage":"Failed to create HTTP client","messagePattern":"Failed to create HTTP client","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/gpui-photo-grid/src/main.rs","lineNumber":29,"sourceCode":"    // Get configuration from environment\n    let socket_addr = env::var(\"SD_SOCKET_ADDR\").unwrap_or_else(|_| \"127.0.0.1:6969\".to_string());\n\n    let http_url = env::var(\"SD_HTTP_URL\").unwrap_or_else(|_e| \"http://127.0.0.1:56851\".to_string());\n\n    let library_id = env::var(\"SD_LIBRARY_ID\").expect(\"SD_LIBRARY_ID environment variable must be set\");\n\n    let initial_path = env::var(\"SD_INITIAL_PATH\").unwrap_or_else(|_e| \"/Users/jamespine/Desktop\".to_string());\n\n    println!(\"Starting GPUI Photo Grid\");\n    println!(\"  Socket: {}\", socket_addr);\n    println!(\"  HTTP: {}\", http_url);\n    println!(\"  Library: {}\", library_id);\n    println!(\"  Path: {}\", initial_path);\n\n    // Create HTTP client for image loading\n    let http_client = Arc::new(\n        reqwest_client::ReqwestClient::user_agent(\"spacedrive-gpui\")\n            .expect(\"Failed to create HTTP client\"),\n    );\n\n    Application::new()\n        .with_http_client(http_client)\n        .run(move |cx: &mut App| {\n            cx.activate(true);\n\n            cx.open_window(\n                WindowOptions {\n                    window_bounds: Some(WindowBounds::Windowed(Bounds::centered(\n                        None,\n                        size(px(1200.0), px(800.0)),\n                        cx,\n                    ))),\n                    titlebar: Some(TitlebarOptions {\n                        title: Some(\"Spacedrive Media Grid\".into()),\n                        appears_transparent: false,\n                        ..Default::default()","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/gpui-photo-grid/src/main.rs#L11-L47","documentation":"main builds a reqwest-backed HTTP client (gpui ReqwestClient::user_agent) for image loading and expects construction to succeed. user_agent returns Err only when the underlying reqwest Client cannot be built, essentially always a TLS backend initialization failure or process resource exhaustion at startup. The expect converts that rare condition into an immediate panic.","triggerScenarios":"TLS backend init failure (broken rustls/native-tls feature mix in the build); fd/memory exhaustion at process start; exotic sandboxed environments blocking client construction.","commonSituations":"Custom build with TLS features stripped or conflicting; almost never seen in stock builds.","solutions":["Rebuild with the crate's default feature set (rustls) and unchanged dependencies","Check process limits (ulimit -n) and memory if construction fails at startup","If reproducible with default features, capture the inner error before the expect and report it as a build/toolchain issue"],"exampleFix":"// before: expect hides the underlying cause\nReqwestClient::user_agent(\"spacedrive-gpui\").expect(\"Failed to create HTTP client\");\n\n// after: surface the inner error on failure\nlet http_client = ReqwestClient::user_agent(\"spacedrive-gpui\")\n    .unwrap_or_else(|e| panic!(\"Failed to create HTTP client: {e}\"));","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Construction happens once at startup; on failure print the inner error and exit non-zero\nlet client = match ReqwestClient::user_agent(\"spacedrive-gpui\") {\n    Ok(c) => Arc::new(c),\n    Err(e) => {\n        eprintln!(\"HTTP client construction failed: {e}\");\n        std::process::exit(1);\n    }\n};","preventionTips":["Build the client once and reuse it; do not construct clients per request","Keep default TLS features intact in builds that ship","Treat construction failure as an environment/build defect, not a runtime condition"],"tags":["http-client","reqwest","panic","startup"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}