{"record":{"id":"02ebb211c48f3b27","repo":"xai-org/x-algorithm","slug":"expects-name-value-pairs-but-a-s-received","errorCode":null,"errorMessage":"expects <name>: <value> pairs, but a %s received","messagePattern":"expects <name>: <value> pairs, but a (.+?) received","errorType":"validation","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/function/collection/Copy.java","lineNumber":118,"sourceCode":"  private static Copy ofStructTuple(ImmutableList<ASTNode> children) throws SemanticCheckFailure {\n    StructTupleType structTupleType = (StructTupleType) children.get(0).getReturnType();\n\n    List<String> fieldNames = Lists.newArrayList(structTupleType.fieldNames);\n    List<Type> fieldTypes = Lists.newArrayList(structTupleType.fieldTypes);\n\n    ImmutableList.Builder<Type> argTypeBuilder = ImmutableList.builder();\n    argTypeBuilder.add(structTupleType);\n\n    ImmutableList.Builder<ASTNode> argBuilder = ImmutableList.builder();\n    argBuilder.add(children.get(0));\n\n    int[] overriddenFieldIndices = new int[children.size()];\n\n    for (int i = 1; i < children.size(); i++) {\n      ASTNode child = children.get(i);\n\n      if (!(child instanceof ToPair)) {\n        throw new SemanticCheckFailure(\n            String.format(\"expects <name>: <value> pairs, but a %s received\", child));\n      }\n\n      String fieldName = ((Constant) child.getChildren().get(0)).getValue().toString();\n      Type fieldType = ((ASTNode) child.getChildren().get(1)).getReturnType();\n\n      argBuilder.add((ASTNode) child.getChildren().get(1));\n      argTypeBuilder.add(fieldType);\n\n      int fieldIndex = fieldNames.indexOf(fieldName);\n      if (fieldIndex < 0) {\n        fieldNames.add(fieldName);\n        fieldTypes.add(fieldType);\n        overriddenFieldIndices[i] = fieldNames.size() - 1;\n      } else if (!Type.isDivergentTo(fieldTypes.get(fieldIndex), fieldType)) {\n        overriddenFieldIndices[i] = fieldIndex;\n      } else {\n        throw new SemanticCheckFailure(","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/function/collection/Copy.java#L100-L136","documentation":"When Copy() targets a StructTuple, every override argument (index 1..n) must literally be a ToPair node (i.e. fieldName: value syntax). Any other AST node type fails semantic checking with this message. Note this check is stricter than the map path: it requires the node to be a ToPair instance, not merely pair-like.","triggerScenarios":"Calling Copy(struct, bareValue), Copy(struct, anotherStruct), or passing a computed expression node where a literal name: value pair is required.","commonSituations":"Programmatically constructing the children list and including non-ToPair nodes; refactoring struct update syntax to positional values.","solutions":["Use explicit field override syntax: Copy(myStruct, fieldName: value)","When building the AST, wrap name/value children in ToPair nodes before calling Copy.of"],"exampleFix":"// before\nCopy(userStruct, \"bob\")\n// after\nCopy(userStruct, name: \"bob\")","handlingStrategy":"validation","validationCode":"// host code: require ToPair nodes for struct Copy\nfor (int i = 1; i < children.size(); i++) {\n  if (!(children.get(i) instanceof ToPair)) {\n    throw new IllegalArgumentException(\"expected fieldName: value, got \" + children.get(i));\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use literal name: value syntax for struct overrides","When building ASTs programmatically, wrap pairs with ToPair explicitly"],"tags":["botmaker","semantic-check","struct-tuple","pair-argument","copy"],"backgroundTag":"invalid-function-arguments","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}