{"record":{"id":"c5a42e37c415259b","repo":"Hmbown/CodeWhale","slug":"reviewed-plugin-stage-could-not-be-opened-for-laun","errorCode":null,"errorMessage":"reviewed plugin stage could not be opened for launch","messagePattern":"reviewed plugin stage could not be opened for launch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp.rs","lineNumber":680,"sourceCode":"    }\n\n    pub(crate) fn prepare_stdio_launch(\n        &self,\n        server_name: &str,\n        command: &str,\n        args: &[String],\n        cwd: Option<&Path>,\n    ) -> Result<ReviewedStdioLaunch> {\n        self.validate_before_stdio_spawn(server_name)?;\n        let staged_root = self\n            .authority\n            .staged_manifest\n            .parent()\n            .context(\"reviewed plugin stage manifest has no parent\")?;\n        let validated = crate::plugins::manifest::PluginManifest::validate_from_path(\n            &self.authority.staged_manifest,\n        )\n        .map_err(|_| anyhow::anyhow!(\"reviewed plugin stage could not be opened for launch\"))?;\n        if validated.content_hash != self.authority.content_hash\n            || validated.capability_hash != self.authority.capability_hash\n        {\n            anyhow::bail!(\"reviewed plugin stage changed before stdio launch\");\n        }\n\n        let mut launch = ReviewedStdioLaunch {\n            command: std::ffi::OsString::from(command),\n            args: args.iter().map(std::ffi::OsString::from).collect(),\n            cwd: cwd.map(Path::to_path_buf),\n            opened_files: Vec::new(),\n            #[cfg(unix)]\n            cwd_fd: None,\n        };\n        if Path::new(command).is_absolute() {\n            launch.bind_command(staged_root, Path::new(command), &validated.file_hashes)?;\n        }\n        // Darwin descriptor paths lose Node's module filename, package.json","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp.rs#L662-L698","documentation":"Before launching a reviewed plugin's stdio MCP server, prepare_stdio_launch re-validates the staged manifest from disk with PluginManifest::validate_from_path. If the staged file cannot be read/parsed/validated at all, the launch is refused with this opaque error; the underlying cause is deliberately collapsed so unvalidated content never reaches launch. A companion check (hash comparison) catches the file having merely changed.","triggerScenarios":"Calling prepare_stdio_launch when the staged manifest file is missing, deleted between review and launch, unreadable (permissions), or corrupt/unparseable so validate_from_path returns Err.","commonSituations":"A temp/staging directory cleaned up by the OS or another process between plugin review and launch, race with a plugin update replacing the stage, filesystem permission changes, or a partially written manifest.","solutions":["Re-stage the plugin: rerun the review/install flow so the manifest is written and validated before launch.","Check the staged manifest path exists and is readable (ls/stat the staged_manifest path).","Look for processes (cleaners, tmpreaper, concurrent plugin updates) deleting the staging directory.","Log the inner validate_from_path error in a dev build to pinpoint whether it's I/O or schema failure."],"exampleFix":"// before\nlet launch = prepare.launch_stdio(&plugin).await?;\n// after\nif !std::path::Path::new(&stage.staged_manifest).exists() {\n    stage = plugin_registry.restage(&plugin.id).await?; // re-review + re-stage\n}\nlet launch = prepare.launch_stdio(&plugin).await?;","handlingStrategy":"validation","validationCode":"// verify the staged manifest is present and parses before requesting launch\nlet path = &stage.staged_manifest;\nif !path.exists() { stage = registry.restage(&plugin.id).await?; }\nlet _ = crate::plugins::manifest::PluginManifest::validate_from_path(path)?;","typeGuard":"fn stage_launchable(stage: &StagedPlugin) -> bool {\n    stage.staged_manifest.exists()\n        && PluginManifest::validate_from_path(&stage.staged_manifest).is_ok()\n}","tryCatchPattern":"match prepare.launch_stdio(&plugin).await {\n    Err(e) if e.to_string().contains(\"could not be opened for launch\") => {\n        let fresh = registry.restage(&plugin.id).await?; // re-review + re-stage\n        prepare.launch_stdio_from(&fresh).await\n    }\n    other => other,\n}","preventionTips":["Exclude staging dirs from tmp cleaners and OS cleanup","Re-stage after every plugin update before launching","Check file permissions on the staging directory","Launch promptly after review; don't hold stale stages across sessions"],"tags":["mcp","plugin","manifest","staging","security"],"backgroundTag":"file-read-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}