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
- Validate fieldName against getFieldNames()/metadataMap before setting
- Fix or remove stale field names in the rule/config
- 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
- Validate default-record configs against the thrift schema in CI
- Keep example records in schema-checked fixtures
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
- field name %s is not found in struct tuple class %s
- field %s not found in the metadata of thrift class %s
- field %s not found in the metadata of thrift class %s
- field name %s is not an underscore followed by a number for
- type checking expression %s failed: invalid argument type: %
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/e0fcaad8e1dda06c.
Report an issue: GitHub.