{"record":{"id":"29ad9fd892a0f3ba","repo":"xai-org/x-algorithm","slug":"derived-feature-s-has-d-parameters-received-d","errorCode":null,"errorMessage":"Derived Feature %s has %d parameters, received %d","messagePattern":"Derived Feature (.+?) has (.+?) parameters, received (.+?)","errorType":"validation","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/Compiler.java","lineNumber":1170,"sourceCode":"\n    Optional<DerivedFeature> dfOpt = context.getDerivedFeature(funcName);\n    if (!dfOpt.isPresent()) {\n      throw new SemanticCheckFailure(String.format(\n          \"%s is not a derived feature function\", funcName));\n    }\n\n    DerivedFeature derivedFeature = dfOpt.get();\n    context.trackUsage(derivedFeature);\n\n    List<Tuple3<Tree, String, Optional<Tree>>> params = derivedFeature.getParams();\n    boolean isLogged = derivedFeature.isLogged();\n\n    List<ASTNode> args = children;\n    if (params.size() != children.size()) {\n\n      if (params.size() < children.size()\n          || !params.get(children.size()).getThird().isPresent()) {\n        throw new SemanticCheckFailure(String.format(\n            \"Derived Feature %s has %d parameters, received %d\",\n            funcName, params.size(), children.size()));\n      }\n\n      ImmutableList.Builder<ASTNode> builder = ImmutableList.builder();\n      builder.addAll(children);\n      for (int i = children.size(); i < params.size(); i++) {\n        Tree tree = params.get(i).getThird().get();\n        ASTNode child = createASTNodeTree(context, tree);\n        builder.add(child);\n      }\n      args = builder.build();\n    }\n\n    List<Pair<String, ASTNode>> variables = Lists.newArrayListWithCapacity(params.size());\n    context.addScope();\n    for (int i = 0; i < params.size(); i++) {\n      String paramName = params.get(i).getSecond();","sourceCodeStart":1152,"sourceCodeEnd":1188,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/Compiler.java#L1152-L1188","documentation":"A derived feature call must supply an argument for every parameter, except trailing parameters that have defaults. The error fires when too many arguments are given, or a skipped parameter has no default value.","triggerScenarios":"Calling df(a, b, c) when df has 2 params; or calling df(a) when df has 2 params and the second lacks a default (params.size() > children.size() and the first missing param has no default).","commonSituations":"Signature drift after adding/removing a parameter without updating call sites, or assuming a parameter is optional when no default was declared.","solutions":["Match the call's argument count to the declared parameter list","Add default values to optional parameters in the derived feature declaration, or always pass them explicitly","Update stale call sites after signature changes"],"exampleFix":"// before\nderived feature greet(name, punctuation = \".\") = ...\nvalue = greet(\"hi\", \"!\", \"?\")\n// after\nvalue = greet(\"hi\", \"!\")","handlingStrategy":"validation","validationCode":"if (args.size() > params.size() || (args.size() < params.size() && !params.get(args.size()).hasDefault()))\n  throw new IllegalArgumentException(\"Arity mismatch for \" + funcName);","typeGuard":null,"tryCatchPattern":"catch (SemanticCheckFailure e) { if (e.getMessage().contains(\"parameters, received\")) reportArity(e); else throw e; }","preventionTips":["Declare defaults for optional parameters","Regenerate call sites when signatures change"],"tags":["botmaker","derived-feature","arity","arguments"],"backgroundTag":"function-arity-mismatch","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}