{"record":{"id":"6a2662a259fdeda1","repo":"databendlabs/databend","slug":"failed-to-register-null-constant","errorCode":null,"errorMessage":"Failed to register NULL constant: {}","messagePattern":"Failed to register NULL constant: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/control/src/lua_support.rs","lineNumber":425,"sourceCode":"        .set(\"new_grpc_client\", new_grpc_client)\n        .map_err(|e| anyhow::anyhow!(\"Failed to register new_grpc_client: {}\", e))?;\n\n    // Register new_admin_client function\n    let new_admin_client = lua\n        .create_function(|_lua, address: String| {\n            let client = MetaAdminClient::new(&address);\n            Ok(LuaAdminClient::new(client))\n        })\n        .map_err(|e| anyhow::anyhow!(\"Failed to create new_admin_client function: {}\", e))?;\n\n    metactl_table\n        .set(\"new_admin_client\", new_admin_client)\n        .map_err(|e| anyhow::anyhow!(\"Failed to register new_admin_client: {}\", e))?;\n\n    // Export NULL constant to metactl namespace\n    metactl_table\n        .set(\"NULL\", Value::NULL)\n        .map_err(|e| anyhow::anyhow!(\"Failed to register NULL constant: {}\", e))?;\n\n    // Register spawn function that delegates to tokio::task::spawn_local\n    let spawn_fn = lua\n        .create_function(|_lua, func: mlua::Function| {\n            #[allow(clippy::disallowed_methods)]\n            let handle = tokio::task::spawn_local(async move {\n                match func.call_async::<mlua::Value>(()).await {\n                    Ok(result) => result,\n                    Err(e) => {\n                        eprintln!(\"Spawned task error: {}\", e);\n                        mlua::Value::Nil\n                    }\n                }\n            });\n\n            Ok(LuaTask {\n                handle: Rc::new(RefCell::new(Some(handle))),\n            })","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/control/src/lua_support.rs#L407-L443","documentation":"Raised in setup_lua_environment when setting the built-in NULL constant into the metactl Lua table fails. Registration of this sentinel value is part of initializing the metactl scripting environment; failure means the Lua runtime rejected the assignment and script environment setup is aborted.","triggerScenarios":"Assignment of the NULL constant to the metactl table failing — corrupted Lua state, mlua version/feature mismatch, or memory pressure.","commonSituations":"Same init-failure family as the other metactl table registrations; typically seen in constrained or misbuilt environments running Lua-scripted metactl commands.","solutions":["Retry in a normal environment with adequate memory","Rebuild metactl with a consistent mlua version and feature flags","Upgrade to a release fixing the mlua set() failure","Confirm the Lua state was freshly created by setup_lua_environment and not pre-modified"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match run_lua_script(&script) {\n    Err(e) if e.to_string().contains(\"Failed to register NULL constant\") => {\n        eprintln!(\"Lua NULL export failed: {e}; verify mlua build and retry\");\n    }\n    other => other?,\n}","preventionTips":["Smoke-test Lua scripting (including NULL availability) after deployments","Keep mlua versions and features consistent in the build","Avoid pre-modifying the Lua state before setup_lua_environment","Run scripted commands with adequate memory limits"],"tags":["lua","mlua","registration"],"backgroundTag":"module-init-failed","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"}