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

  1. 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).
  2. Convert the struct to a thriftjava/scrooge representation handled by a strato-JSON-capable serializer before export.
  3. Exclude struct-typed subfields from strato JSON export, or flatten them into primitives/strings.
  4. 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

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


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/7cf20937e3d998a4. Report an issue: GitHub.