xai-org/x-algorithm · error · SemanticCheckFailure
expects a Pair argument but get %s.
Error message
expects a Pair argument but get %s.
What it means
When Copy()'s first argument is map-like, every subsequent argument must be pair-like (a key/value pair produced by ToPair, typically via name: value syntax). Any non-pair child fails semantic checking with this message.
Source
Thrown at botmaker/src/java/com/twitter/botmaker/function/collection/Copy.java:58
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(
"expects a Pair argument but get %s.", children.get(i).getReturnType())
);
}
}
Signature signature = new Signature(
ImmutableList.of(Type.mapOf(TPA, TPB)),
Type.pairOf(TPA, TPB),
Type.mapOf(TPA, TPB)
);
return new Copy("Copy", children) {
@Override
public Signature getSignature() {
return signature;
}
View on GitHub (pinned to 24c60942c5)
Solutions
- Rewrite extra arguments as name: value pairs, e.g. Copy(myMap, key: newValue)
- Ensure each override argument is produced by ToPair (the ':' operator)
Example fix
// before Copy(myMap, "newvalue") // after Copy(myMap, status: "newvalue")
Defensive patterns
Strategy: validation
Validate before calling
// host code: verify every child after the first is pair-like
for (int i = 1; i < children.size(); i++) {
if (!children.get(i).getReturnType().pairLike()) {
throw new IllegalArgumentException("argument " + i + " must be a name: value pair");
}
} Prevention
- Always write Copy map overrides as key: value pairs
- Don't mix positional values into Copy calls
When it happens
Trigger: Calling Copy(map, someNonPairValue) — e.g. Copy(myMap, 42) or Copy(myMap, anotherMap) instead of Copy(myMap, key: value).
Common situations: Passing bare values instead of name: value pairs, or mixing map-update and struct-update syntax in one call.
Related errors
- expects <name>: <value> pairs, but a %s received
- expects at least one argument.
- Copy function only supports Map or StructTuple.
- StructTuple field %s expects type %s, but %s received.
- StructTuple expects pairs of name and values, but a %s recei
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/0f5ef12b92748ab5.
Report an issue: GitHub.