{"record":{"id":"540cfe29efc14782","repo":"xai-org/x-algorithm","slug":"pairs-are-not-supported-in-strato-json","errorCode":null,"errorMessage":"Pairs are not supported in strato JSON","messagePattern":"Pairs are not supported in strato JSON","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/Serializer.java","lineNumber":1313,"sourceCode":"\n      @Override\n      protected Pair deserialize(TProtocol prot) throws Exception {\n\n        return Pair.of(\n            keyType.serializer.deserialize(prot, true),\n            valType.serializer.deserialize(prot, true));\n      }\n\n      @Override\n      protected void toScript(GenScript script, Pair pair) throws Exception {\n        keyType.serializer.genScript(script, pair.getFirst());\n        script.builder.append(\": \");\n        valType.serializer.genScript(script, pair.getSecond());\n      }\n\n      @Override\n      protected void toStratoJson(GenScript script, Pair pair) {\n        throw new IllegalArgumentException(\"Pairs are not supported in strato JSON\");\n      }\n    };\n  }\n\n  public static Serializer<Tuple> tupleOf(Type... typeParams) {\n    return new Serializer<Tuple>() {\n\n      @Override\n      public void computeFingerprint(Hasher hasher, Tuple tuple) throws Exception {\n        for (Type type : typeParams) {\n          type.computerFingerprint(hasher);\n        }\n\n        for (int index = 0; index < tuple.size(); index++) {\n          hasher.putInt(index);\n          if (tuple.get(index) != null) {\n            typeParams[index].serializer.computeFingerprint(hasher, tuple.get(index));\n          }","sourceCodeStart":1295,"sourceCodeEnd":1331,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/Serializer.java#L1295-L1331","documentation":"The map serializer's toStratoJson override throws IllegalArgumentException because Pair (the key/value pair of a map entry, per the visible genScript usage of pair.getSecond()) has no representation in strato JSON. When a value containing pairs is converted to the strato JSON format, serialization deliberately fails rather than emitting malformed JSON.","triggerScenarios":"Constructing a Serializer via the pair/map factory (Serializer code path around line 1313) and then calling genStratoJson on data containing Pair values; e.g. serializing a feature whose type includes a map/pair type to strato JSON.","commonSituations":"Defining a botmaker rule field or constant with a pair/map type and then enabling strato JSON export/serving for it; reusing a serializer built for fingerprinting in a strato JSON context.","solutions":["Restructure the data so pairs are represented as a thrift struct or a list of key/value structs, which have strato JSON support via thriftStructOf.","Avoid calling genStratoJson on serializers built with pairOf; use genScript (fingerprint path) for those values.","If strato output is required, change the underlying schema to use a struct-tuple or named struct instead of Pair."],"exampleFix":"// before\nSerializer<Pair<A,B>> s = Serializer.pairOf(aS, bS);\ns.genStratoJson(script, pair); // throws Pairs are not supported in strato JSON\n\n// after\nMyPairStruct struct = MyPairStruct(pair.getFirst(), pair.getSecond());\nSerializer.thriftStructOf(MyPairStruct.class).genStratoJson(script, struct);","handlingStrategy":"validation","validationCode":"if (typeIncludesPair(featureType)) {\n  throw new IllegalArgumentException(featureName + \" uses Pair, not strato-JSON serializable\");\n}","typeGuard":"static boolean stratoSerializableType(Serializer<?> s) {\n  return !isPairSerializer(s); // track serializer kind when constructed\n}","tryCatchPattern":"catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Pairs are not supported\")) {\n    // use genScript fingerprint path instead\n  } else throw e;\n}","preventionTips":["Prefer thrift structs over Pair in any type that may be exported to strato.","Lint feature definitions for pair/map-of-pair types before registration."],"tags":["strato-json","serialization","pairs","java"],"backgroundTag":"unsupported-type-for-strato-json","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}