xai-org/x-algorithm · error · SemanticCheckFailure
StructTuple expects pairs of name and values, but a %s recei
Error message
StructTuple expects pairs of name and values, but a %s received
What it means
Every child of ToStructTuple() must be a ToPair node representing a fieldName: value pair. Any non-ToPair child fails semantic checking with the child's string representation. Like Copy-on-struct, this is a syntactic requirement, not just a type check.
Source
Thrown at botmaker/src/java/com/twitter/botmaker/function/collection/ToStructTuple.java:51
@Override
protected Object apply(Context<Runtime> context, List<Object> args) throws Exception {
return StructTuple.of(fieldNames, args);
}
public static ToStructTuple of(
String funcName, ImmutableList<ASTNode> children) throws SemanticCheckFailure {
if (children.size() == 0) {
throw new SemanticCheckFailure("StructTuple should have at least one field");
}
ImmutableList.Builder<String> fieldNamesBuilder = ImmutableList.builder();
ImmutableList.Builder<Type> fieldTypesBuilder = ImmutableList.builder();
ImmutableList.Builder<ASTNode> childrenBuilder = ImmutableList.builder();
for (ASTNode child : children) {
if (!(child instanceof ToPair)) {
throw new SemanticCheckFailure(
String.format(
"StructTuple expects pairs of name and values, but a %s received", child));
}
fieldNamesBuilder.add(((Constant) child.getChildren().get(0)).getValue().toString());
fieldTypesBuilder.add(((ASTNode) child.getChildren().get(1)).getReturnType());
childrenBuilder.add((ASTNode) child.getChildren().get(1));
}
ImmutableList<String> fieldNames = fieldNamesBuilder.build();
ImmutableList<Type> fieldTypes = fieldTypesBuilder.build();
Signature signature = new Signature(
fieldTypes,
Type.structTupleOf(fieldNames, fieldTypes)
);
return new ToStructTuple(funcName, fieldNames, childrenBuilder.build()) {
View on GitHub (pinned to 24c60942c5)
Solutions
- Write every field as name: value: ToStructTuple(id: 1, name: "x")
- When building the AST, wrap each name/value in ToPair before calling ToStructTuple.of
Example fix
// before
ToStructTuple("id", 1)
// after
ToStructTuple(id: 1) Defensive patterns
Strategy: validation
Validate before calling
// host code: all children must be ToPair
for (ASTNode c : children) {
if (!(c instanceof ToPair)) throw new IllegalArgumentException("expected pair, got " + c);
} Prevention
- Write struct fields as name: value only
- Never pass bare positional values to ToStructTuple
When it happens
Trigger: ToStructTuple("a", "b", 1) — bare positional values instead of name: value pairs; or programmatically passing non-ToPair AST nodes.
Common situations: Copying positional function-call style into struct construction; generating children from unvalidated config.
Related errors
- expects <name>: <value> pairs, but a %s received
- expects a Pair argument but get %s.
- StructTuple field %s expects type %s, but %s received.
- StructTuple should have at least one field
- Cannot convert nodes to pairs: offset = %d, nodes to convert
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/9dfa4d3d3339a24a.
Report an issue: GitHub.