{"record":{"id":"7cf20937e3d998a4","repo":"xai-org/x-algorithm","slug":"thriftscala-objects-are-not-supported-in-strato-js","errorCode":null,"errorMessage":"Thriftscala objects are not supported in strato JSON","messagePattern":"Thriftscala 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":1621,"sourceCode":"\n        @Override\n        protected void serialize(TProtocol prot, ThriftStruct value) throws TException {\n          codec.encode(value, prot);\n        }\n\n        @Override\n        protected T deserialize(TProtocol prot) throws TException {\n          return (T) codec.decode(prot);\n        }\n\n        @Override\n        protected void toScript(GenScript script, T value) {\n          script.builder.append(\"NULL\");\n        }\n\n        @Override\n        protected void toStratoJson(GenScript script, T value) {\n          throw new IllegalArgumentException(\n              \"Thriftscala objects are not supported in strato JSON\");\n        }\n      };\n    } catch (Exception e) {\n      throw new SemanticCheckFailure(\n          String.format(\"Failed to create serializer for ThriftStruct %s: %s\",\n              clazz.getName(), e.toString())\n      );\n    }\n  }\n\n  private static final class TByteBufferTransport extends TTransport {\n    private ByteBuffer buffer;\n\n    public TByteBufferTransport(ByteBuffer buf) {\n      this.buffer = buf;\n    }\n","sourceCodeStart":1603,"sourceCodeEnd":1639,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/Serializer.java#L1603-L1639","documentation":"Inside thriftStructOf, a serializer for scrooge ThriftStruct classes is being constructed; the toStratoJson method shown throws IllegalArgumentException stating Thriftscala objects are not supported in strato JSON. Unlike the outer thriftStructOf path used by deserialize (which is fine), this particular anonymous serializer's strato JSON hook is a stub, so any genStratoJson call routed to it fails.","triggerScenarios":"A ThriftStruct-typed value reaching genStratoJson through a serializer produced by this branch of thriftStructOf (e.g. a nested struct inside another value being exported to strato JSON).","commonSituations":"Nested thriftscala structs inside features that are exported to strato JSON; enabling strato serving on a feature whose type graph includes structs handled by this stub serializer; version differences where only some struct serializers implement strato JSON.","solutions":["Check the exception's origin: if it comes from this stub, route serialization through a serializer variant whose toStratoJson is implemented (compare with the thriftOf/genStratoJson-capable serializers in the same file).","Convert the struct to a thriftjava/scrooge representation handled by a strato-JSON-capable serializer before export.","Exclude struct-typed subfields from strato JSON export, or flatten them into primitives/strings.","If you own the library, implement toStratoJson for this serializer rather than throwing."],"exampleFix":"// before\nserializer.genStratoJson(script, thriftscalaValue);\n// throws Thriftscala objects are not supported in strato JSON\n\n// after\nMap<String, Object> flat = flatten(thriftscalaValue);\nSerializer.mapOf(stringOf(), objectSerializer()).genStratoJson(script, flat);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Thriftscala objects are not supported in strato JSON\")) {\n    return flattenToPrimitives(structValue); // degrade to a flat representation\n  }\n  throw e;\n}","preventionTips":["Verify which serializer variant a struct routes to before enabling strato export.","Cover nested structs in strato JSON unit tests.","Track serializer capabilities per type instead of assuming all thriftStructOf serializers are JSON-capable."],"tags":["strato-json","thriftscala","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"}