xai-org/x-algorithm · error · SemanticCheckFailure

Field %s is not defined in thrift type %s

Error message

Field %s is not defined in thrift type %s

What it means

ThriftType.setFieldValue writes a value onto a TBase object by looking up fieldName in the thrift metadata. If the field is not defined, SemanticCheckFailure 'Field %s is not defined in thrift type %s' is thrown before any assignment.

Source

Thrown at botmaker/src/java/com/twitter/botmaker/compiler/types/ThriftType.java:209

    TBase thriftObj = (TBase) typeBase.newInstance();
    return thriftObj;
  }

  public TBase newInstance(Map<Object, Object> map) throws Exception {
    TBase thriftObj = newInstance();
    for (Map.Entry<Object, Object> entry : map.entrySet()) {
      String fn = entry.getKey().toString();
      setFieldValue(thriftObj, fn, entry.getValue());
    }
    return thriftObj;
  }

  @SuppressWarnings("unchecked")
  public void setFieldValue(
      TBase thriftObj, String fieldName, Object fieldValue) throws Exception {
    FieldMetaData metaData = metadataMap.get(fieldName);
    if (metaData == null) {
      throw new SemanticCheckFailure(
          String.format("Field %s is not defined in thrift type %s", fieldName, typeBase.getName())
      );
    }
    Object value = extractFieldValue(metaData.valueMetaData, fieldValue, fieldName);
    thriftObj.setFieldValue(thriftObj.fieldForId(metaData.fieldId), value);
  }

  private static Object getListFieldValue(FieldValueMetaData valueMetaData, Object fieldValue) {
    ListMetaData listMetaData = (ListMetaData) valueMetaData;
    FieldValueMetaData elemMetaData = listMetaData.elemMetaData;
    if (!isConversionRequired(elemMetaData)) {
      return fieldValue;
    }

    ImmutableList.Builder<Object> builder = ImmutableList.builder();
    for (Object val : (Collection) fieldValue) {
      Object converted = getFieldValue(elemMetaData, val);
      builder.add(converted);

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Validate fieldName against getFieldNames()/metadataMap before setting
  2. Fix or remove stale field names in the rule/config
  3. Deploy matching generated thrift classes

Example fix

// before
thriftType.setFieldValue(rec, "oldField", v);
// after
if (thriftType.getFieldNames().contains("newField")) {
  thriftType.setFieldValue(rec, "newField", v);
}
Defensive patterns

Strategy: validation

Validate before calling

if (!thriftType.getFieldNames().contains(fieldName)) {
  throw new IllegalArgumentException("field not in thrift type");
}

Try / catch

catch SemanticCheckFailure around setFieldValue/newInstance; log field name and typeBase

Prevention

When it happens

Trigger: Calling setFieldValue(obj, fieldName, value) (often from newInstance when building default records) with a fieldName absent from the TBase class's FieldMetaData.

Common situations: Constructing default/example records from config that names fields removed by a schema change; environment mismatch where one service's rules reference fields another's thrift jar lacks.

Related errors


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