xai-org/x-algorithm · error · SemanticCheckFailure

Unsupported field type %s

Error message

Unsupported field type %s

What it means

getFieldValueMetadata builds FieldValueMetaData for a field's runtime class, supporting collections, ThriftStruct, and ThriftEnum. Any other runtime class falls through to SemanticCheckFailure 'Unsupported field type'.

Source

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

      Manifest valueManifest = (Manifest) manifest.typeArguments().apply(0);
      FieldValueMetaData elemMetaData = getFieldValueMetadata(valueManifest);
      return new ListMetaData(elemMetaData);
    } else if (scala.collection.Set.class.equals(runtimeClass)) {
      Manifest valueManifest = (Manifest) manifest.typeArguments().apply(0);
      FieldValueMetaData elemMetaData = getFieldValueMetadata(valueManifest);
      return new SetMetaData(elemMetaData);
    } else if (scala.collection.Map.class.equals(runtimeClass)) {
      Manifest keyManifest = (Manifest) manifest.typeArguments().apply(0);
      Manifest valueManifest = (Manifest) manifest.typeArguments().apply(1);
      FieldValueMetaData keyMetaData = getFieldValueMetadata(keyManifest);
      FieldValueMetaData valueMetaData = getFieldValueMetadata(valueManifest);
      return new MapMetaData(keyMetaData, valueMetaData);
    } else if (ThriftStruct.class.isAssignableFrom(runtimeClass)) {
      return new ThriftStructMetaData(runtimeClass);
    } else if (ThriftEnum.class.isAssignableFrom(runtimeClass)) {
      return new ThriftEnumMetaData((Class<? extends ThriftEnum>) runtimeClass);
    } else {
      throw new SemanticCheckFailure(
          String.format("Unsupported field type %s", runtimeClass.toString()));
    }
  }

  private static ThriftStructCodec getThriftStructCodec(
      Class<? extends ThriftStruct> thriftClass) throws SemanticCheckFailure {

    try {
      Class<? extends ThriftStructCodec> codecClass =
          (Class<? extends ThriftStructCodec>) ClassCache.forName(thriftClass.getName() + "$");
      Field codecField = codecClass.getField("MODULE$");
      ThriftStructCodec codec = (ThriftStructCodec) codecField.get(null);
      return codec;
    } catch (Exception e) {
      throw new SemanticCheckFailure(
          String.format("Cannot load ThriftStruct Codec for %s: $s",
              thriftClass.getName(), e.toString()));
    }

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Upgrade botmaker/compiler to a version supporting the field's type
  2. Remove/exclude the unsupported field from the rule
  3. Verify the field's Java class is a scrooge ThriftStruct/ThriftEnum or standard collection

Example fix

// before
field: weirdField  // runtime class not supported
// after
field: structField  // ThriftStruct-typed field, or upgrade botmaker
Defensive patterns

Strategy: try-catch

Validate before calling

Class<?> c = fieldClass;
boolean ok = Map.class.isAssignableFrom(c) || Set.class.isAssignableFrom(c)
    || List.class.isAssignableFrom(c) || ThriftStruct.class.isAssignableFrom(c)
    || ThriftEnum.class.isAssignableFrom(c);

Try / catch

catch SemanticCheckFailure 'Unsupported field type' during metadata build; skip or fail fast per rule with the offending class name

Prevention

When it happens

Trigger: A thrift field whose Java runtime class is not a Map/Set/List, ThriftStruct, or ThriftEnum (e.g. plain Java types, TBase structs mixed into scrooge unions, or arbitrary classes) reaching getFieldValueMetadata via fieldValueMetaData/elemMetaData/keyMetaData/valueMetaData.

Common situations: New field type introduced in a thrift IDL that the botmaker compiler version predates; mixing apache-thrift TBase structs with scrooge ThriftStruct types; custom thrift annotations producing unexpected Java classes.

Related errors


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