xai-org/x-algorithm · error · IllegalArgumentException
Thriftscala objects are not supported in strato JSON
Error message
Thriftscala objects are not supported in strato JSON
What it means
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.
Source
Thrown at botmaker/src/java/com/twitter/botmaker/compiler/Serializer.java:1621
@Override
protected void serialize(TProtocol prot, ThriftStruct value) throws TException {
codec.encode(value, prot);
}
@Override
protected T deserialize(TProtocol prot) throws TException {
return (T) codec.decode(prot);
}
@Override
protected void toScript(GenScript script, T value) {
script.builder.append("NULL");
}
@Override
protected void toStratoJson(GenScript script, T value) {
throw new IllegalArgumentException(
"Thriftscala objects are not supported in strato JSON");
}
};
} catch (Exception e) {
throw new SemanticCheckFailure(
String.format("Failed to create serializer for ThriftStruct %s: %s",
clazz.getName(), e.toString())
);
}
}
private static final class TByteBufferTransport extends TTransport {
private ByteBuffer buffer;
public TByteBufferTransport(ByteBuffer buf) {
this.buffer = buf;
}
View on GitHub (pinned to 24c60942c5)
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.
Example fix
// before serializer.genStratoJson(script, thriftscalaValue); // throws Thriftscala objects are not supported in strato JSON // after Map<String, Object> flat = flatten(thriftscalaValue); Serializer.mapOf(stringOf(), objectSerializer()).genStratoJson(script, flat);
Defensive patterns
Strategy: try-catch
Try / catch
catch (IllegalArgumentException e) {
if (e.getMessage().contains("Thriftscala objects are not supported in strato JSON")) {
return flattenToPrimitives(structValue); // degrade to a flat representation
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Pairs are not supported in strato JSON
- Tuples are not supported in strato JSON
- StructTuples are not supported in strato JSON
- Thriftjava objects are not supported in strato JSON
- Thrift enums are not supported in strato JSON
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/7cf20937e3d998a4.
Report an issue: GitHub.