{"record":{"id":"456476e757fa9e36","repo":"apache/druid","slug":"requires-at-least-d-arguments","errorCode":null,"errorMessage":"requires at least %d arguments","messagePattern":"requires at least (.+?) arguments","errorType":"validation","errorClass":"ExpressionValidationException","httpStatus":400,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java","lineNumber":88,"sourceCode":"      if (count == 0) {\n        throw validationFailed(\"does not accept arguments\");\n      } else if (count == 1) {\n        throw validationFailed(\"requires 1 argument\");\n      }\n      throw validationFailed(\"requires %d arguments\", count);\n    }\n  }\n\n  /**\n   * Helper method for implementors performing validation to check if there are at least as many arguments as specified\n   */\n  default void validationHelperCheckMinArgumentCount(List<Expr> args, int count)\n  {\n    if (args.size() < count) {\n      if (count == 1) {\n        throw validationFailed(\"requires at least 1 argument\");\n      }\n      throw validationFailed(\"requires at least %d arguments\", count);\n    }\n  }\n\n  default void validationHelperCheckArgumentRange(List<Expr> args, int start, int end)\n  {\n    if (args.size() < start || args.size() > end) {\n      throw validationFailed(\"requires %d to %d arguments\", start, end);\n    }\n  }\n\n  /**\n   * Helper method for implementors performing validation to check if argument count is any of specified counts\n   */\n  default void validationHelperCheckAnyOfArgumentCount(List<Expr> args, int... counts)\n  {\n    boolean satisfied = false;\n    for (int count : counts) {\n      if (args.size() == count) {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/math/expr/NamedFunction.java#L70-L106","documentation":"Generic argument-count guard used by Druid's named expression functions: validationHelperCheckMinArgumentCount(args, count) fires when a function requiring at least 'count' arguments is called with fewer. The message is a template from the shared validation helper naming the minimum required count. It indicates a malformed expression call site (too few arguments), not a data error; supply at least the required number of arguments in the SQL/expression.","triggerScenarios":"Calling e.g. a function declared with validationHelperCheckMinArgumentCount(args, 3) with only 2 arguments.","commonSituations":"Omitting required trailing operands, partial dynamic expression assembly, or misreading variadic functions as fully optional.","solutions":["Provide at least N arguments","Inspect the function implementation for the declared minimum","Split the logic or use a different function if fewer operands are genuinely available"],"exampleFix":"// before\nx = substring(str)  // requires at least 2\n// after\nx = substring(str, 1, 3)","handlingStrategy":"validation","validationCode":"if (args.size() < minCount) { throw new IllegalArgumentException(funcName + \" requires at least \" + minCount + \" arguments, got \" + args.size()); }","typeGuard":"boolean hasMinArity(List<Expr> args, int min) { return args != null && args.size() >= min; }","tryCatchPattern":"try { expr = Parser.parse(exprString); } catch (ExpressionValidationException e) { // report missing operands with expected minimum }","preventionTips":["Check minimum-arity functions before assembling arguments","Don't assume variadic functions have fully optional operands","Add arity assertions in expression-builder helpers"],"tags":["expression","argument-count","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}