{"record":{"id":"d05fbd5ac050507d","repo":"xai-org/x-algorithm","slug":"thriftjava-objects-are-not-supported-in-strato-jso","errorCode":null,"errorMessage":"Thriftjava objects are not supported in strato JSON","messagePattern":"Thriftjava objects 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":1547,"sourceCode":"            Object fieldValue = thriftObj.getFieldValue(thriftObj.fieldForId(metaData.fieldId));\n            Type.STRING.serializer.genScript(script, fieldName);\n            script.builder.append(\": \");\n\n            if (fieldType == Type.STRING && fieldValue != null) {\n              fieldType.serializer.genScript(script, fieldValue.toString());\n            } else {\n              fieldType.serializer.genScript(script, fieldValue);\n            }\n          }\n\n          script.level--;\n          script.builder.append(\")\");\n        }\n      }\n\n      @Override\n      protected void toStratoJson(GenScript script, T thriftjava) {\n        throw new IllegalArgumentException(\"Thriftjava objects are not supported in strato JSON\");\n      }\n    };\n  }\n\n  public static <T extends TEnum> Serializer<T> thriftEnumOf(Class<T> typeEnum) {\n    ImmutableMap.Builder<Integer, T> builder = ImmutableMap.builder();\n    for (Object v : EnumSet.allOf((Class<? extends Enum>) typeEnum)) {\n      T e = (T) v;\n      builder.put(e.getValue(), e);\n    }\n\n    Map<Integer, T> enumMap = builder.build();\n\n    return new Serializer<T>() {\n\n      @Override\n      public void computeFingerprint(Hasher hasher, T value) {\n        hasher.putInt(value.getValue());","sourceCodeStart":1529,"sourceCodeEnd":1565,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/Serializer.java#L1529-L1565","documentation":"The serializer for generated thriftjava classes (TBase implementations, created via thriftOf) implements toScript for fingerprinting but its toStratoJson throws IllegalArgumentException, because raw thriftjava objects are not supported in the strato JSON path. Strato JSON serialization is implemented only for scrooge ThriftStruct classes (thriftStructOf).","triggerScenarios":"Calling genStratoJson on a value serialized with Serializer.thriftOf(SomeTBaseClass.class); i.e. mixing the thriftjava serializer into a strato JSON export.","commonSituations":"Feature definitions referencing java thrift classes while the serving/export layer expects scala (scrooge) structs; partial migration from thriftjava to thriftscala; defaulting to thriftOf because the class is handy at the call site.","solutions":["Use the scrooge-generated scala class instead: Serializer.thriftStructOf(ThriftScalaClass.class) which supports strato JSON.","Convert the thriftjava object to its scala equivalent (via Generated.scalaConverter or the standard java<->scala converters) before strato JSON serialization.","Keep thriftOf-based serializers only on the fingerprint/genScript path."],"exampleFix":"// before\nSerializer.thriftOf(MyObj.class).genStratoJson(script, myJavaObj);\n// throws Thriftjava objects are not supported in strato JSON\n\n// after\nMyObjScala scalaObj = MyObjScala.javaToScala(myJavaObj);\nSerializer.thriftStructOf(MyObjScala.class).genStratoJson(script, scalaObj);","handlingStrategy":"type-guard","validationCode":"if (value instanceof TBase) {\n  throw new IllegalArgumentException(\"Convert thriftjava to thriftscala before strato JSON\");\n}","typeGuard":"static boolean stratoSerializableThrift(Object v) {\n  return v == null || v instanceof ThriftStruct; // scrooge only, not TBase\n}","tryCatchPattern":"catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Thriftjava objects\")) {\n    Object scala = ThriftConverters.toScala(value);\n    return serializeStratoJson(scala);\n  }\n  throw e;\n}","preventionTips":["Standardize on scrooge (scala) structs for strato-facing features.","Add a lint that rejects thriftOf serializers in strato JSON contexts.","Keep java<->scala converters next to feature type definitions."],"tags":["strato-json","thrift","thriftjava","serialization","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"}