xai-org/x-algorithm · error · SemanticCheckFailure

field %s not found in the metadata of thrift class %s

Error message

field %s not found in the metadata of thrift class %s

What it means

ThriftStructType.getFieldType looks up a field in the class's thrift FieldMetaData map. A missing field means the scrooge-generated class has no such thrift field, and SemanticCheckFailure is raised.

Source

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

    return createType(typeBase, Function.exfunc0(() ->
        new ThriftStructType(typeBase)
    ));
  }

  @Override
  public Set<String> getFieldNames() {
    return metadataMap.keySet();
  }

  public FieldMetaData getFieldMetadata(String fieldName) {
    return metadataMap.get(fieldName);
  }

  @Override
  public Type getFieldType(String fieldName) throws SemanticCheckFailure {
    FieldMetaData fieldMetaData = metadataMap.get(fieldName);
    if (fieldMetaData == null) {
      throw new SemanticCheckFailure(
          String.format("field %s not found in the metadata of thrift class %s",
              fieldName, typeBase.getName()));
    }

    return fieldMetaData.valueMetaData.getType();
  }

  @SuppressWarnings("unchecked")
  @Override
  public boolean isSetValue(ThriftStruct thriftObj, String fieldName) {
    if (this.isUnion) {
      ThriftUnion thriftUnion = (ThriftUnion) thriftObj;
      Option<ThriftStructFieldInfo> fieldInfo = thriftUnion.unionStructFieldInfo();
      if (fieldInfo.isEmpty()) {
        return false;
      } else {
        return fieldInfo.get().tfield().name.equals(fieldName);
      }

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Correct the field name to match the current thrift struct definition
  2. Regenerate and redeploy the thrift classes matching the rule's schema version
  3. List valid fields from metadataMap/getFieldNames before lookup

Example fix

// before
thriftStructType.getFieldType("created_at"); // field is 'createdAt'
// after
thriftStructType.getFieldType("createdAt");
Defensive patterns

Strategy: type-guard

Validate before calling

if (!thriftStructType.getFieldNames().contains(fieldName)) { ... }

Type guard

boolean hasField(ThriftStructType t, String f) { return t.getFieldNames().contains(f); }

Try / catch

catch SemanticCheckFailure; map to 'unknown field <name> on <class>' and fail rule validation early

Prevention

When it happens

Trigger: Calling getFieldType(fieldName) on a ThriftStructType where fieldName is not a thrift field of the underlying scrooge-generated struct (misspelled, renamed, or added after the class was compiled).

Common situations: Thrift schema renames/removes a field but botmaker rules still reference the old name; stale generated thrift classes on the classpath; rules written against a newer schema than deployed.

Related errors


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