{"record":{"id":"60ebbb4fb5107001","repo":"jlcodes99/cockpit-tools","slug":"expected-launch-path-must-exist","errorCode":null,"errorMessage":"expected launch path must exist","messagePattern":"expected launch path must exist","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cockpit-core/src/modules/process_core_matching.rs","lineNumber":1359,"sourceCode":"    #[cfg(target_os = \"macos\")]\n    {\n        let entries = collect_antigravity_process_entries_macos();\n        if !entries.is_empty() {\n            return filter_entries_by_expected_launch_path(\"AG\", entries, expected_launch.clone());\n        }\n        let entries = collect_antigravity_process_entries_from_ps();\n        if !entries.is_empty() {\n            return filter_entries_by_expected_launch_path(\"AG\", entries, expected_launch.clone());\n        }\n        // macOS 下避免回退到 sysinfo，防止触发 TCC「其他 App 数据」授权弹窗\n        return Vec::new();\n    }\n\n    #[cfg(target_os = \"windows\")]\n    {\n        let expected = expected_launch\n            .as_deref()\n            .expect(\"expected launch path must exist\");\n        let entries = collect_antigravity_process_entries_from_powershell(expected);\n        if !entries.is_empty() {\n            return entries;\n        }\n        if strict_process_detect_enabled() {\n            crate::modules::logger::log_warn(\n                \"[AG Probe] strict mode enabled and PowerShell returned empty; skip sysinfo fallback\",\n            );\n            return Vec::new();\n        }\n        crate::modules::logger::log_warn(\n            \"[AG Probe] PowerShell returned empty; fallback to sysinfo probe\",\n        );\n        return collect_antigravity_process_entries_from_sysinfo_fallback(expected);\n    }\n\n    #[cfg(target_os = \"linux\")]\n    {","sourceCodeStart":1341,"sourceCodeEnd":1377,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/crates/cockpit-core/src/modules/process_core_matching.rs#L1341-L1377","documentation":"collect_antigravity_process_entries (crates/cockpit-core/src/modules/process_core_matching.rs:1359) runs on Windows inside #[cfg(target_os = \"windows\")] and calls expected_launch.as_deref().expect(\"expected launch path must exist\") before probing processes via PowerShell. The Option expected_launch holds the resolved Antigravity launch executable path; when the caller's probe could not resolve it, the Option is None and the .expect panics, aborting the process-entry collection used by close_antigravity_instances and resolve_antigravity_pid.","triggerScenarios":"Calling close_antigravity_instances or resolve_antigravity_pid on Windows when the Antigravity install path cannot be resolved (uninstalled, portable install, non-standard install directory, or registry/FS lookup failure), so expected_launch arrives as None.","commonSituations":"Antigravity was uninstalled or moved after first run; app installed in a custom directory the resolver doesn't scan; corrupted install metadata; running the close/PID commands before Antigravity was ever launched on the machine.","solutions":["Verify Antigravity is installed at a standard location and reinstall/repair it if the executable is missing.","Return an empty entry list (or an explicit error) when expected_launch is None instead of unwrapping.","Check the path-resolution code that produces expected_launch and add the custom install directory it misses.","On non-Windows this block is compiled out — confirm the panic actually occurs on a Windows build."],"exampleFix":"// before\nlet expected = expected_launch.as_deref().expect(\"expected launch path must exist\");\n// after\nlet Some(expected) = expected_launch.as_deref() else {\n    crate::modules::logger::log_warn(\"[Antigravity Probe] launch path unresolved; skipping\");\n    return Vec::new();\n};","handlingStrategy":"validation","validationCode":"// Before invoking close/resolve commands, check the launch path resolves:\nif (await invoke('resolve_antigravity_launch_path') == null) {\n  console.warn('Antigravity launch path not found; skipping process probe');\n}","typeGuard":"fn has_launch_path(expected_launch: &Option<String>) -> bool {\n  expected_launch.as_deref().map(|p| !p.trim().is_empty()).unwrap_or(false)\n}","tryCatchPattern":"match std::panic::catch_unwind(|| collect_antigravity_process_entries()) {\n  Ok(entries) => entries,\n  Err(_) => { log_warn(\"probe panicked\"); Vec::new() }\n}","preventionTips":["Verify Antigravity is installed at a standard location before using close/PID features.","Replace .expect on optional launch paths with graceful empty-result fallbacks.","Keep install-path resolver metadata updated after app upgrades or moves."],"tags":["rust","windows","process-detection","panic","option-unwrap"],"backgroundTag":"unwrap-on-none-path","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}