xai-org/x-algorithm · error · SemanticCheckFailure

Cannot load ThriftUnion fieldInfos for %s: $s

Error message

Cannot load ThriftUnion fieldInfos for %s: $s

What it means

getUnionFieldInfos reflectively reads ThriftUnionFieldInfo array from a scrooge union's codec to build field info. Any exception during that reflective read is wrapped in SemanticCheckFailure naming the codec class.

Source

Thrown at botmaker/src/java/com/twitter/botmaker/compiler/types/ThriftStructType.java:377

        JavaConverters.seqAsJavaList(codec.metaData().fieldInfos());
    return fieldInfos;
  }

  private static List<ThriftStructFieldInfo> getUnionFieldInfos(
      ThriftStructCodec codec) throws SemanticCheckFailure {
    try {
      Method fieldInfosMethod = codec.getClass().getMethod("fieldInfos");
      List<ThriftUnionFieldInfo> fieldInfos =
          JavaConverters.seqAsJavaList(
              (scala.collection.Seq<ThriftUnionFieldInfo>) fieldInfosMethod.invoke(codec));

      ImmutableList.Builder<ThriftStructFieldInfo> builder = ImmutableList.builder();
      for (ThriftUnionFieldInfo fieldInfo : fieldInfos) {
        builder.add(fieldInfo.structFieldInfo());
      }
      return builder.build();
    } catch (Exception e) {
      throw new SemanticCheckFailure(
          String.format("Cannot load ThriftUnion fieldInfos for %s: $s",
              codec.getClass().getName(), e.toString()));
    }
  }

  private static class TBotMakerMapProtocol extends TProtocol {

    public interface Scope {

      FieldValueMetaData getMetaData();

      Object getValue();
    }

    public interface StructScope extends Scope {
      TField readField();
    }

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Pin scrooge-runtime to the same version used to generate the thrift classes
  2. Evict duplicate scrooge/thrift jars from the dependency tree (check for classpath conflicts)
  3. Regenerate the union classes and redeploy together with botmaker

Example fix

// before
// pom: scrooge-runtime 21.2.0, generated code from 24.x -> reflective read fails
// after
<dependency><groupId>com.twitter</groupId><artifactId>scrooge-runtime</artifactId><version>24.x</version></dependency>
Defensive patterns

Strategy: try-catch

Try / catch

catch SemanticCheckFailure 'Cannot load ThriftUnion fieldInfos'; instruct checking scrooge-runtime version alignment

Prevention

When it happens

Trigger: Constructing a ThriftStructType over a ThriftUnion whose codec does not expose the expected union FieldInfos field/method — incompatible scrooge version, non-union struct passed where a union is expected, or shaded companion classes.

Common situations: Scrooge runtime version differs from the version that generated the union classes; jar conflicts putting two scrooge versions on the classpath; referring to a union type in a botmaker rule after an IDL/toolchain upgrade.

Related errors


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