{"record":{"id":"6b8f0891cd8d0363","repo":"Hmbown/CodeWhale","slug":"mcp-import-preview-failed","errorCode":null,"errorMessage":"MCP import preview failed","messagePattern":"MCP import preview failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/ui/handlers.rs","lineNumber":806,"sourceCode":"        }\n        crate::tui::app::McpUiAction::ImportList => {\n            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_external_import_status_text(&workspace, &path, plugins.as_ref())\n            })\n            .await\n            {\n                Ok(text) => {\n                    message = Some(text);\n                    Ok(())\n                }\n                Err(_) => Err(anyhow::anyhow!(\"MCP import preview failed\")),\n            }\n        }\n        crate::tui::app::McpUiAction::ImportApprove { name }\n        | crate::tui::app::McpUiAction::ImportDecline { name } => {\n            let approve = approve_import;\n            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)) => {","sourceCodeStart":788,"sourceCodeEnd":824,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/ui/handlers.rs#L788-L824","documentation":"Generic fallback error raised when the MCP import preview task completes but its inner operation returns Err — the actual preview failure detail is discarded (`Err(_)`) and replaced with this fixed message. The preview renders what an import would change (servers, config diff) before the user approves it.","triggerScenarios":"Requesting an MCP import preview (handle_mcp_ui_action ImportPreview path) where the awaited preview returns Err — e.g. unreadable or malformed source config, invalid JSON/YAML in the imported file, or an IO error reading the file.","commonSituations":"Importing an MCP config exported from another tool with a schema the parser rejects; pointing the import at a nonexistent path; permission errors reading the source file; newer/older config format version mismatch.","solutions":["Check the source MCP config file exists, is readable, and parses as valid JSON/YAML.","Validate the file's schema against the expected MCP config format (server entries, required fields).","Retry the preview — the underlying error is swallowed, so verify the input rather than guessing from this message.","If the format is from a different tool/version, convert it to the native MCP config shape first."],"exampleFix":"// before\nErr(_) => Err(anyhow::anyhow!(\"MCP import preview failed\")),\n// after: keep the cause\nErr(err) => Err(anyhow::anyhow!(\"MCP import preview failed: {err:#}\")),","handlingStrategy":"validation","validationCode":"// before requesting a preview, ensure the source parses\nlet text = std::fs::read_to_string(&import_path)?;\nlet parsed: serde_json::Value = serde_json::from_str(&text)\n    .or_else(|_| serde_yaml::from_str(&text))?;\nif parsed.get(\"servers\").is_none() {\n    eprintln!(\"import file has no 'servers' section\");\n}","typeGuard":null,"tryCatchPattern":"match preview_import(&import_path).await {\n    Ok(text) => show_preview(text),\n    Err(e) => show_error(format!(\"MCP import preview failed: {e:#}\")),\n}","preventionTips":["Validate the import file (exists, readable, valid JSON/YAML, `servers` present) before previewing.","Confirm the file matches the expected MCP config schema/version for this build.","Avoid hand-editing exported configs before import; import the original export.","Surface the inner error — the fixed message hides the real cause."],"tags":["mcp","import","preview","config"],"backgroundTag":"unexpected-response-shape","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"}