{"record":{"id":"9dfa4d3d3339a24a","repo":"xai-org/x-algorithm","slug":"structtuple-expects-pairs-of-name-and-values-but-9dfa4d","errorCode":null,"errorMessage":"StructTuple expects pairs of name and values, but a %s received","messagePattern":"StructTuple expects pairs of name and values, but a (.+?) received","errorType":"validation","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/function/collection/ToStructTuple.java","lineNumber":51,"sourceCode":"\n  @Override\n  protected Object apply(Context<Runtime> context, List<Object> args) throws Exception {\n    return StructTuple.of(fieldNames, args);\n  }\n\n  public static ToStructTuple of(\n      String funcName, ImmutableList<ASTNode> children) throws SemanticCheckFailure {\n\n    if (children.size() == 0) {\n      throw new SemanticCheckFailure(\"StructTuple should have at least one field\");\n    }\n\n    ImmutableList.Builder<String> fieldNamesBuilder = ImmutableList.builder();\n    ImmutableList.Builder<Type> fieldTypesBuilder = ImmutableList.builder();\n    ImmutableList.Builder<ASTNode> childrenBuilder = ImmutableList.builder();\n    for (ASTNode child : children) {\n      if (!(child instanceof ToPair)) {\n        throw new SemanticCheckFailure(\n            String.format(\n                \"StructTuple expects pairs of name and values, but a %s received\", child));\n      }\n\n      fieldNamesBuilder.add(((Constant) child.getChildren().get(0)).getValue().toString());\n      fieldTypesBuilder.add(((ASTNode) child.getChildren().get(1)).getReturnType());\n      childrenBuilder.add((ASTNode) child.getChildren().get(1));\n    }\n\n    ImmutableList<String> fieldNames = fieldNamesBuilder.build();\n    ImmutableList<Type> fieldTypes = fieldTypesBuilder.build();\n    Signature signature = new Signature(\n        fieldTypes,\n        Type.structTupleOf(fieldNames, fieldTypes)\n    );\n\n    return new ToStructTuple(funcName, fieldNames, childrenBuilder.build()) {\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/function/collection/ToStructTuple.java#L33-L69","documentation":"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.","triggerScenarios":"ToStructTuple(\"a\", \"b\", 1) — bare positional values instead of name: value pairs; or programmatically passing non-ToPair AST nodes.","commonSituations":"Copying positional function-call style into struct construction; generating children from unvalidated config.","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"],"exampleFix":"// before\nToStructTuple(\"id\", 1)\n// after\nToStructTuple(id: 1)","handlingStrategy":"validation","validationCode":"// host code: all children must be ToPair\nfor (ASTNode c : children) {\n  if (!(c instanceof ToPair)) throw new IllegalArgumentException(\"expected pair, got \" + c);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write struct fields as name: value only","Never pass bare positional values to ToStructTuple"],"tags":["botmaker","semantic-check","pair-argument","struct-tuple"],"backgroundTag":"invalid-function-arguments","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}