xai-org/x-algorithm · error · SemanticCheckFailure

expects at least one argument.

Error message

expects at least one argument.

What it means

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.

Source

Thrown at botmaker/src/java/com/twitter/botmaker/function/collection/Copy.java:40

import com.twitter.botmaker.function.conversion.ToPair;

public abstract class Copy extends FunctionNode<Runtime> {

  private static final Type TPA = Type.newGenericType();
  private static final Type TPB = Type.newGenericType();

  public Copy(String exprText, List<ASTNode> children) throws SemanticCheckFailure {
    super(exprText, children);
  }

  @Override
  protected CacheLevel getCacheLevel() {
    return CacheLevel.Global;
  }

  public static Copy of(ImmutableList<ASTNode> children) throws SemanticCheckFailure {
    if (children.size() < 1) {
      throw new SemanticCheckFailure("expects at least one argument.");
    }

    Type nodeType = children.get(0).getReturnType();
    if (nodeType.mapLike()) {
      return ofMap(children);
    } else if (nodeType.structTupleLike()) {
      return ofStructTuple(children);
    } else {
      throw new SemanticCheckFailure("Copy function only supports Map or StructTuple.");
    }

  }

  private static Copy ofMap(ImmutableList<ASTNode> children) throws SemanticCheckFailure {

    for (int i = 1; i < children.size(); i++) {
      if (!children.get(i).getReturnType().pairLike()) {
        throw new SemanticCheckFailure(String.format(

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Provide the source expression as the first argument, e.g. Copy(myMap, key: value)
  2. If building the AST programmatically, assert children.size() >= 1 before calling Copy.of

Example fix

// before
Copy()
// after
Copy(userProfile, name: "bob")
Defensive patterns

Strategy: validation

Validate before calling

// host code before Copy.of
if (children == null || children.isEmpty()) {
  throw new IllegalArgumentException("Copy requires a source argument");
}
Copy.of(children);

Prevention

When it happens

Trigger: Writing Copy() with no arguments, or programmatically building a Copy node with an empty ImmutableList of children.

Common situations: Dynamically generating rule code and passing an empty argument list, or deleting the source argument while editing a rule.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/8ff43891b75d6a8e. Report an issue: GitHub.