{"record":{"id":"d0432fe306e25ae1","repo":"databendlabs/databend","slug":"function-id-not-found","errorCode":null,"errorMessage":"function id not found","messagePattern":"function id not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/expression/src/expression.rs","lineNumber":1169,"sourceCode":"            RemoteExpr::Cast {\n                span,\n                is_try,\n                expr,\n                dest_type,\n            } => Expr::Cast(Cast {\n                span: *span,\n                is_try: *is_try,\n                expr: Box::new(expr.as_expr(fn_registry)),\n                dest_type: dest_type.clone(),\n            }),\n            RemoteExpr::FunctionCall {\n                span,\n                id,\n                generics,\n                args,\n                return_type,\n            } => {\n                let function = fn_registry.get(id).expect(\"function id not found\");\n                Expr::FunctionCall(FunctionCall {\n                    span: *span,\n                    id: id.clone(),\n                    function,\n                    generics: generics.clone(),\n                    args: args.iter().map(|arg| arg.as_expr(fn_registry)).collect(),\n                    return_type: return_type.clone(),\n                })\n            }\n            RemoteExpr::LambdaFunctionCall {\n                span,\n                name,\n                args,\n                lambda_expr,\n                lambda_display,\n                return_type,\n            } => Expr::LambdaFunctionCall(LambdaFunctionCall {\n                span: *span,","sourceCodeStart":1151,"sourceCodeEnd":1187,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/expression/src/expression.rs#L1151-L1187","documentation":"When converting a registry-backed expression node, FunctionCall expressions look up their function id in the FunctionRegistry (fn_registry.get(id)). This expect panics when the id is absent — the expression references a function that was never registered (or was registered under another id) in the registry used at expression-build time.","triggerScenarios":"Calling as_expr(fn_registry) on an expression AST containing a FunctionCall whose id is not present in the supplied registry — e.g. a function removed/renamed between AST construction and lowering, or two different registry instances used.","commonSituations":"Version changes where builtin/aggregate functions were renamed or dropped while serialized plans or embedders (bendpy) reference old ids; registering functions into one registry but lowering expressions with another.","solutions":["Ensure the same FunctionRegistry instance used to parse/build expressions is passed to as_expr.","Verify all function ids referenced by the plan are registered before lowering (register missing builtins/aggregates).","If plans are persisted across versions, re-plan or migrate them after a function rename/removal.","Handle get(id) with a proper error (unknown function id <id>) instead of expect to surface the offending id."],"exampleFix":"// before\nlet function = fn_registry.get(id).expect(\"function id not found\");\n// after\nlet function = fn_registry.get(id).ok_or_else(||\n    ErrorCode::UnknownFunction(format!(\"function id not found: {id}\")))?;","handlingStrategy":"try-catch","validationCode":"if !fn_registry.contains(id) {\n    return Err(ErrorCode::UnknownFunction(format!(\"function id not found: {id}\")));\n}","typeGuard":null,"tryCatchPattern":"// prefer registry lookup returning Result\nlet function = match fn_registry.get(id) {\n    Some(f) => f,\n    None => return Err(ErrorCode::UnknownFunction(format!(\"unknown function id: {id}\"))),\n};","preventionTips":["Use a single shared FunctionRegistry for parse and lowering","Register all referenced functions before as_expr","Migrate persisted plans after builtin renames","Replace expect with a typed unknown-function error carrying the id"],"tags":["rust","panic","registry","function-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}