{"record":{"id":"c87cc2b8e72947ae","repo":"databendlabs/databend","slug":"lua-execution-error","errorCode":null,"errorMessage":"Lua execution error: {}","messagePattern":"Lua execution error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/binaries/metactl/main.rs","lineNumber":341,"sourceCode":"\n    fn new_grpc_client(\n        &self,\n        addresses: Vec<String>,\n    ) -> Result<Arc<ClientHandle<DatabendRuntime>>, CreationError> {\n        lua_support::new_grpc_client(addresses)\n    }\n}\n\n#[allow(clippy::disallowed_types)]\nasync fn execute_lua_script(\n    lua: &Lua,\n    local: &tokio::task::LocalSet,\n    script: &str,\n) -> anyhow::Result<()> {\n    local\n        .run_until(lua.load(script).exec_async())\n        .await\n        .map_err(|e| anyhow::anyhow!(\"Lua execution error: {}\", e))\n}\n\n#[derive(Debug, Clone, Deserialize, Subcommand)]\nenum CtlCommand {\n    #[command(verbatim_doc_comment)]\n    /// Show cluster status: node info, replication, voters, etc.\n    ///\n    /// Example:\n    ///   metactl status --grpc-api-address 127.0.0.1:9191\n    ///\n    /// Sample output:\n    ///   BinaryVersion: v1.2.345-nightly-abc1234(rust-1.75-nightly-2024-01-01T12:00:00)\n    ///   DataVersion: V002\n    ///   RaftLogSize: 1234\n    ///   SnapshotKeyCount: 5678\n    ///   Node: id=0 raft=127.0.0.1:28004\n    ///   State: Leader\n    ///   Leader: Node { name: \"0\", endpoint: 127.0.0.1:28004 }","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/binaries/metactl/main.rs#L323-L359","documentation":"When executing an embedded Lua script (via the mlua async runtime), any Lua runtime/compile error is mapped to 'Lua execution error: {}'. metactl uses Lua scripts to fetch data from admin APIs; a script failure means the requested operation could not complete.","triggerScenarios":"Calling metactl commands that run Lua (e.g. metrics/status collection) when the script fails to compile or raises a Lua error, such as an HTTP error inside the script or invalid response handling.","commonSituations":"Target metasrv returning error bodies the script doesn't expect; admin API unreachable from inside the Lua script; internal script bugs from custom/modified scripts.","solutions":["Inspect the wrapped message for the underlying Lua error and fix the script or its inputs","Confirm the target admin API address is correct and responding before running the script","Report/upgrade if a shipped script fails against a newer metasrv version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"curl -sf http://<admin-api-address>/v1/health || echo 'target admin api down; lua script will fail'","typeGuard":null,"tryCatchPattern":"run_lua_script_with_result(&lua_script)\n    .await\n    .map_err(|e| eprintln!(\"Lua execution error: {}; verify admin api and script\", e))","preventionTips":["Test Lua scripts against a live admin API before production use","Pin metactl and metasrv versions together","Include HTTP status checks inside the script with clear Lua error messages"],"tags":["lua","scripting","metactl"],"backgroundTag":"http-error-response","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}