{"record":{"id":"94395e749f508211","repo":"janhq/jan","slug":"executable-must-have-a-parent-directory","errorCode":null,"errorMessage":"Executable must have a parent directory","messagePattern":"Executable must have a parent directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src-tauri/src/core/mcp/helpers.rs","lineNumber":407,"sourceCode":"        }\n        Err(e) => {\n            log::error!(\"Failed to start MCP server {name} on first attempt: {e}\");\n            Err(e)\n        }\n    }\n}\n\nasync fn schedule_mcp_start_task<R: Runtime>(\n    app: tauri::AppHandle<R>,\n    servers: SharedMcpServers,\n    name: String,\n    config: Value,\n) -> Result<(), String> {\n    let app_path = get_jan_data_folder_path(app.clone());\n    let exe_path = env::current_exe().expect(\"Failed to get current exe path\");\n    let exe_parent_path = exe_path\n        .parent()\n        .expect(\"Executable must have a parent directory\");\n    let bin_path = exe_parent_path.to_path_buf();\n\n    let config_params = extract_command_args(&config)\n        .ok_or_else(|| format!(\"Failed to extract command args from config for {name}\"))?;\n\n    if let (Some(\"http\"), Some(url)) = (\n        config_params.transport_type.as_deref(),\n        config_params.url.clone(),\n    ) {\n        let transport = StreamableHttpClientTransport::with_client(\n            reqwest::Client::builder()\n                .default_headers({\n                    // Map envs to request headers\n                    let mut headers: tauri::http::HeaderMap = reqwest::header::HeaderMap::new();\n                    for (key, value) in config_params.headers.iter() {\n                        if let Some(v_str) = value.as_str() {\n                            // Try to map env keys to HTTP header names (case-insensitive)\n                            // Most HTTP headers are Title-Case, so we try to convert","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/src-tauri/src/core/mcp/helpers.rs#L389-L425","documentation":"This is a panic (.expect) from Path::parent() on the exe path obtained from current_exe(). parent() returns None only when the path is a bare root or a single component with no directory separator. Since current_exe() returns absolute paths on all supported platforms, this panic is effectively unreachable in practice — it exists as a safety invariant assertion.","triggerScenarios":"current_exe() somehow returns a path like \"/\" or a bare filename with no directory component. A custom platform or exotic FS where the path representation lacks a parent. Theoretically impossible on standard Linux/macOS/Windows where current_exe always yields a full path.","commonSituations":"Not encountered in real usage. Would only manifest on deeply unusual platforms or after a std library bug. Listed here for completeness.","solutions":["Replace .expect with unwrap_or to fall back to the current directory.","Log a warning and use std::env::current_dir() if parent is None.","This is a defensive assertion — no user action is needed unless it actually fires."],"exampleFix":"// before\nlet exe_parent_path = exe_path.parent().expect(\"Executable must have a parent directory\");\n\n// after\nlet exe_parent_path = exe_path.parent().unwrap_or_else(|| {\n    log::warn!(\"exe path has no parent; using current dir\");\n    std::env::current_dir().unwrap_or_default().as_path()\n});","handlingStrategy":"fallback","validationCode":"// Validate the exe path has a parent before using it\nfn exe_parent_or_cwd(exe: &Path) -> PathBuf {\n    exe.parent()\n        .map(|p| p.to_path_buf())\n        .unwrap_or_else(|| {\n            log::warn!(\"exe path has no parent component: {}\", exe.display());\n            std::env::current_dir().unwrap_or_else(|_| PathBuf::from(\".\"))\n        })\n}","typeGuard":null,"tryCatchPattern":"// Replace .expect with a fallback\nlet bin_path = match exe_path.parent() {\n    Some(p) => p.to_path_buf(),\n    None => {\n        log::warn!(\"exe path has no parent; using current working directory\");\n        std::env::current_dir().unwrap_or_default()\n    }\n};","preventionTips":["Use unwrap_or with a fallback rather than expect for path operations.","This is a defensive assertion — monitor logs if it fires to detect exotic platform issues.","Cache the parent path alongside the exe path at startup."],"tags":["panic","path","parent","mcp","defensive"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}