{"record":{"id":"8ff43891b75d6a8e","repo":"xai-org/x-algorithm","slug":"expects-at-least-one-argument","errorCode":null,"errorMessage":"expects at least one argument.","messagePattern":"expects at least one argument\\.","errorType":"validation","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/function/collection/Copy.java","lineNumber":40,"sourceCode":"import com.twitter.botmaker.function.conversion.ToPair;\n\npublic abstract class Copy extends FunctionNode<Runtime> {\n\n  private static final Type TPA = Type.newGenericType();\n  private static final Type TPB = Type.newGenericType();\n\n  public Copy(String exprText, List<ASTNode> children) throws SemanticCheckFailure {\n    super(exprText, children);\n  }\n\n  @Override\n  protected CacheLevel getCacheLevel() {\n    return CacheLevel.Global;\n  }\n\n  public static Copy of(ImmutableList<ASTNode> children) throws SemanticCheckFailure {\n    if (children.size() < 1) {\n      throw new SemanticCheckFailure(\"expects at least one argument.\");\n    }\n\n    Type nodeType = children.get(0).getReturnType();\n    if (nodeType.mapLike()) {\n      return ofMap(children);\n    } else if (nodeType.structTupleLike()) {\n      return ofStructTuple(children);\n    } else {\n      throw new SemanticCheckFailure(\"Copy function only supports Map or StructTuple.\");\n    }\n\n  }\n\n  private static Copy ofMap(ImmutableList<ASTNode> children) throws SemanticCheckFailure {\n\n    for (int i = 1; i < children.size(); i++) {\n      if (!children.get(i).getReturnType().pairLike()) {\n        throw new SemanticCheckFailure(String.format(","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/function/collection/Copy.java#L22-L58","documentation":"Copy() requires at least one argument (the source map or struct tuple to copy). Copy.of throws SemanticCheckFailure during AST construction when the children list is empty, so the rule fails to compile/build rather than at runtime.","triggerScenarios":"Writing Copy() with no arguments, or programmatically building a Copy node with an empty ImmutableList of children.","commonSituations":"Dynamically generating rule code and passing an empty argument list, or deleting the source argument while editing a rule.","solutions":["Provide the source expression as the first argument, e.g. Copy(myMap, key: value)","If building the AST programmatically, assert children.size() >= 1 before calling Copy.of"],"exampleFix":"// before\nCopy()\n// after\nCopy(userProfile, name: \"bob\")","handlingStrategy":"validation","validationCode":"// host code before Copy.of\nif (children == null || children.isEmpty()) {\n  throw new IllegalArgumentException(\"Copy requires a source argument\");\n}\nCopy.of(children);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the source map/struct as the first argument","When generating rules, validate non-empty arg lists for variadic builders"],"tags":["botmaker","semantic-check","missing-argument","copy"],"backgroundTag":"missing-required-argument","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}