{"record":{"id":"b55211b9e14e4d50","repo":"influxdata/influxdb","slug":"expected-three-arguments","errorCode":null,"errorMessage":"Expected three arguments","messagePattern":"Expected three arguments","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/query_functions/src/date_bin_wallclock.rs","lineNumber":927,"sourceCode":"        fn as_any(&self) -> &dyn std::any::Any {\n            self\n        }\n\n        fn name(&self) -> &'static str {\n            \"test_date_bin_udf\"\n        }\n\n        fn signature(&self) -> &Signature {\n            &self.signature\n        }\n\n        fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {\n            Ok(arg_types[1].clone())\n        }\n\n        fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {\n            let [_, source, origin] = args.args.as_slice() else {\n                panic!(\"Expected three arguments\");\n            };\n            assert_eq!(source.data_type(), origin.data_type());\n            let DataType::Timestamp(_, tz) = source.data_type() else {\n                panic!(\"Expected timestamp data type\");\n            };\n            assert!(tz.is_some());\n            Ok(source.clone())\n        }\n    }\n\n    fn arg_to_fields(args: &[ColumnarValue]) -> Vec<FieldRef> {\n        args.iter()\n            .enumerate()\n            .map(|(idx, val)| Arc::new(Field::new(format!(\"arg_{idx}\"), val.data_type(), false)))\n            .collect()\n    }\n\n    fn return_field(dt: DataType) -> FieldRef {","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/query_functions/src/date_bin_wallclock.rs#L909-L945","documentation":"This panic lives in a test-local mock ScalarUDF's `invoke_with_args` used to validate argument shapes during gapfill tests. It uses a let-else pattern: if the args slice is not exactly `[_, source, origin]` (three arguments), it panics with \"Expected three arguments\". It signals that the mock UDF was invoked with the wrong arity, or the mock itself was wired up incorrectly.","triggerScenarios":"The mock UDF registered in the test is called with fewer or more than 3 arguments — e.g. the test builds the Expr with a wrong number of children, or args.args contains extra values.","commonSituations":"Developers changing the function signature (adding/removing args in tests), or DataFusion version changes altering how ScalarFunctionArgs.args is populated, trigger this while running gapfill tests.","solutions":["Check the call site constructing the mock UDF call and ensure exactly three arguments are passed (stride/source placeholders).","Inspect args.args.len() at the panic to see what was actually delivered.","If a DataFusion upgrade changed argument plumbing, update the mock's let-else pattern accordingly."],"exampleFix":"// before\nlet [_, source, origin] = args.args.as_slice() else {\n    panic!(\"Expected three arguments\");\n};\n// after\nlet [_, source, origin] = args.args.as_slice() else {\n    panic!(\"expected three arguments, got {}: {:?}\", args.args.len(), args.args);\n};","handlingStrategy":"validation","validationCode":"assert_eq!(args.args.len(), 3, \"mock UDF requires exactly 3 args, got {}\", args.args.len());","typeGuard":"fn split3(args: &[ColumnarValue]) -> Option<(&ColumnarValue, &ColumnarValue, &ColumnarValue)> {\n    match args { [a, b, c] => Some((a, b, c)), _ => None }\n}","tryCatchPattern":"let [_, source, origin] = args.args.as_slice() else {\n    panic!(\"expected three arguments, got {}: {:?}\", args.args.len(), args.args);\n};","preventionTips":["Update mock UDFs in lockstep whenever the real function signature changes","Assert argument count at the call site before invoking the mock","After DataFusion upgrades, review ScalarFunctionArgs plumbing for arity changes"],"tags":["rust","test-panic","argument-count","mock-udf"],"backgroundTag":"missing-required-argument","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}