{"record":{"id":"123c2b0d27fa079c","repo":"Hmbown/CodeWhale","slug":"mcp-import-failed","errorCode":null,"errorMessage":"MCP import failed","messagePattern":"MCP import failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/ui/handlers.rs","lineNumber":830,"sourceCode":"            let path = path.clone();\n            let workspace = app.workspace.clone();\n            let plugins = app.plugin_registry.clone();\n            #[cfg(test)]\n            let ticket = crate::test_support::env_scope_ticket();\n            match tokio::task::spawn_blocking(move || {\n                #[cfg(test)]\n                let _membership = crate::test_support::join_env_scope(ticket);\n                mcp_import_apply(&workspace, &path, plugins.as_ref(), &name, approve)\n            })\n            .await\n            {\n                Ok(Ok(msg)) => {\n                    changed = approve;\n                    message = Some(msg);\n                    Ok(())\n                }\n                Ok(Err(err)) => Err(err),\n                Err(_) => Err(anyhow::anyhow!(\"MCP import failed\")),\n            }\n        }\n        crate::tui::app::McpUiAction::Validate | crate::tui::app::McpUiAction::Reload => Ok(()),\n        crate::tui::app::McpUiAction::Retry { .. } => Ok(()),\n    };\n\n    if let Err(err) = action_result {\n        add_mcp_message(app, format!(\"MCP action failed: {err}\"));\n        return;\n    }\n\n    if changed {\n        app.mcp_reload_required = true;\n    }\n    if let Some(message) = message {\n        add_mcp_message(app, message);\n    }\n","sourceCodeStart":812,"sourceCodeEnd":848,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/ui/handlers.rs#L812-L848","documentation":"Fallback error for the MCP import-approve/decline flow: the import task's JoinHandle resolves Err (the spawned task panicked or was cancelled) so no inner result exists. `Ok(Err(err))` cases propagate the real error; only the join failure (`Err(_)`) is replaced by this fixed message. This indicates the import never completed rather than that it failed validation.","triggerScenarios":"Approving or declining an MCP import where the spawned import task panics or is dropped before returning its Result, so `.await` on the handle yields Err and the code maps it to \"MCP import failed\".","commonSituations":"Config write panics (e.g. serialization bug) mid-import; TUI shutting down and cancelling the import task; runtime teardown racing with the user clicking Approve.","solutions":["Retry the import approve action — the task loss is usually a transient cancellation race.","Inspect logs for a panic in the MCP import task and fix the underlying cause (e.g. corrupt target config file).","Verify the target MCP config file is writable and not locked by another process before approving.","If it recurs during shutdown, complete imports before exiting the TUI."],"exampleFix":"// before\nErr(_) => Err(anyhow::anyhow!(\"MCP import failed\")),\n// after: surface the join error for diagnosis\nErr(err) => Err(anyhow::anyhow!(\"MCP import failed: task lost: {err}\")),","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match import_task.await {\n    Ok(Ok(msg)) => apply_import(msg),\n    Ok(Err(e)) => show_error(format!(\"import failed: {e:#}\")),\n    Err(join_err) => {\n        show_error(format!(\"import task lost: {join_err} — retry the approve action\"));\n    }\n}","preventionTips":["Retry the approve/decline action once on a lost task; it is usually a cancellation race.","Ensure the target config file is writable and not concurrently locked before approving.","Complete imports before closing the TUI so teardown cannot cancel the task.","Keep the import task panic-free: validate the approved payload before spawning."],"tags":["mcp","import","tokio","task-join"],"backgroundTag":"channel-closed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T06:17:15.046Z"}