{"record":{"id":"0f5ef12b92748ab5","repo":"xai-org/x-algorithm","slug":"expects-a-pair-argument-but-get-s","errorCode":null,"errorMessage":"expects a Pair argument but get %s.","messagePattern":"expects a Pair argument but get (.+?)\\.","errorType":"validation","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/function/collection/Copy.java","lineNumber":58,"sourceCode":"      throw new SemanticCheckFailure(\"expects at least one argument.\");\n    }\n\n    Type nodeType = children.get(0).getReturnType();\n    if (nodeType.mapLike()) {\n      return ofMap(children);\n    } else if (nodeType.structTupleLike()) {\n      return ofStructTuple(children);\n    } else {\n      throw new SemanticCheckFailure(\"Copy function only supports Map or StructTuple.\");\n    }\n\n  }\n\n  private static Copy ofMap(ImmutableList<ASTNode> children) throws SemanticCheckFailure {\n\n    for (int i = 1; i < children.size(); i++) {\n      if (!children.get(i).getReturnType().pairLike()) {\n        throw new SemanticCheckFailure(String.format(\n            \"expects a Pair argument but get %s.\", children.get(i).getReturnType())\n        );\n      }\n    }\n\n    Signature signature = new Signature(\n        ImmutableList.of(Type.mapOf(TPA, TPB)),\n        Type.pairOf(TPA, TPB),\n        Type.mapOf(TPA, TPB)\n    );\n\n    return new Copy(\"Copy\", children) {\n\n      @Override\n      public Signature getSignature() {\n        return signature;\n      }\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/function/collection/Copy.java#L40-L76","documentation":"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.","triggerScenarios":"Calling Copy(map, someNonPairValue) — e.g. Copy(myMap, 42) or Copy(myMap, anotherMap) instead of Copy(myMap, key: value).","commonSituations":"Passing bare values instead of name: value pairs, or mixing map-update and struct-update syntax in one call.","solutions":["Rewrite extra arguments as name: value pairs, e.g. Copy(myMap, key: newValue)","Ensure each override argument is produced by ToPair (the ':' operator)"],"exampleFix":"// before\nCopy(myMap, \"newvalue\")\n// after\nCopy(myMap, status: \"newvalue\")","handlingStrategy":"validation","validationCode":"// host code: verify every child after the first is pair-like\nfor (int i = 1; i < children.size(); i++) {\n  if (!children.get(i).getReturnType().pairLike()) {\n    throw new IllegalArgumentException(\"argument \" + i + \" must be a name: value pair\");\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write Copy map overrides as key: value pairs","Don't mix positional values into Copy calls"],"tags":["botmaker","semantic-check","pair-argument","copy","map"],"backgroundTag":"invalid-function-arguments","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}