{"record":{"id":"bba3c3ddb70f976f","repo":"ruvnet/RuView","slug":"plugin-id-setup-returned-failure-code-result","errorCode":null,"errorMessage":"plugin `{id}` setup returned failure code {result}","messagePattern":"plugin `(.+?)` setup returned failure code (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v2/crates/homecore-server/src/plugins.rs","lineNumber":217,"sourceCode":"    let mut loaded: Vec<(PluginId, WasmPlugin)> = Vec::with_capacity(discovered.len());\n    for package in discovered {\n        let id = PluginId::new(&package.manifest.domain);\n        let bytes = package\n            .read_module(config.limits)\n            .with_context(|| format!(\"failed reading plugin `{id}`\"))?;\n        let plugin = runtime\n            .load_plugin(&package.manifest, &bytes, hc.clone(), &policy)\n            .with_context(|| format!(\"plugin `{id}` rejected before setup\"))?;\n        let config_entry = serde_json::to_string(&ConfigEntryJson::bootstrap(id.as_str()))?;\n        let setup_plugin = plugin.clone();\n        let result = tokio::task::spawn_blocking(move || setup_plugin.call_setup(&config_entry))\n            .await\n            .with_context(|| format!(\"plugin `{id}` setup task failed\"))?\n            .with_context(|| format!(\"plugin `{id}` setup trapped\"))?;\n        if result != 0 {\n            let _ = plugin.call_teardown();\n            teardown_wasm(loaded).await;\n            anyhow::bail!(\"plugin `{id}` setup returned failure code {result}\");\n        }\n        info!(\n            plugin = %id,\n            package = %package.package_dir.display(),\n            \"signed WASM plugin loaded\"\n        );\n        loaded.push((id, plugin));\n    }\n    Ok(loaded)\n}\n\n#[cfg(feature = \"wasmtime\")]\nasync fn teardown_wasm(plugins: Vec<(PluginId, WasmPlugin)>) {\n    for (_, plugin) in plugins.into_iter().rev() {\n        let _ = tokio::task::spawn_blocking(move || plugin.call_teardown()).await;\n    }\n}\n","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/v2/crates/homecore-server/src/plugins.rs#L199-L235","documentation":"Anyhow bail during WASM plugin loading: the module loaded and its exported setup was invoked (call_setup with a bootstrap ConfigEntryJson), but the guest returned a non-zero exit code. The host reacts by calling the plugin's teardown, running teardown_wasm over already-loaded plugins, and aborting server startup with the plugin id and the exact failure code.","triggerScenarios":"A plugin whose setup() rejects its bootstrap config (missing required config entry, invalid values), a plugin built against a different host ABI/manifest version than this homecore-server, or a guest bug (panic trapped into a failure return). The code in {result} is the plugin's own failure reason.","commonSituations":"Plugins compiled from an older/newer homecore-plugins SDK than the host; required per-plugin configuration not provided before first start; plugin expects capabilities (FS, network) the policy denies; corrupted .wasm artifact.","solutions":["Check the plugin's own logs/stdout around setup -- the non-zero code is its failure reason","Rebuild the plugin against the same homecore-plugins/host version as the server so manifest and ABI match","Provide the configuration the plugin's setup expects (its bootstrap config entry) before it is loaded","To get the server up, temporarily move the failing plugin's directory out of the configured plugin dir, fix it, then restore"],"exampleFix":"# before\nls /etc/homecore/plugins/\n# broken-integration/  (setup returns 3 on missing config)\n./homecore-server --plugin-dir /etc/homecore/plugins\n# error: plugin `broken-integration` setup returned failure code 3\n\n# after\nmv /etc/homecore/plugins/broken-integration /tmp/quarantine/\n./homecore-server   # starts with remaining plugins\n# fix broken-integration setup/config, rebuild the .wasm, move it back","handlingStrategy":"try-catch","validationCode":"// preflight (deploy script): validate each plugin package loads+setups before server start\n// run `homecore-server --plugin-dir <dir> --dry-run-plugins` if available, or load in a scratch\n// harness first; only promote plugins whose setup exits 0 into the production plugin dir","typeGuard":null,"tryCatchPattern":"match load_wasm_plugins(&hc, &config).await {\n    Ok(plugins) => plugins,\n    Err(e) if e.to_string().contains(\"setup returned failure code\") => {\n        tracing::error!(\"plugin failed setup; quarantining: {e}\");\n        quarantine_last_plugin(&config)?; // move dir aside, continue boot without it\n        load_wasm_plugins(&hc, &config).await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Build plugins from the same homecore-plugins SDK commit as the host runtime","Exercise plugin setup in CI against a scratch host before shipping artifacts","Ship each plugin's required config entries alongside its .wasm so bootstrap setup cannot fail on missing values"],"tags":["rust","plugins","wasm","wasmtime","setup","abi-mismatch"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}