xai-org/x-algorithm · error · SemanticCheckFailure
field name %s is not found in struct tuple class %s
Error message
field name %s is not found in struct tuple class %s
What it means
getFieldType on a StructTupleType resolves a field by name. Names not present in fieldNames and not starting with '_' (tuple positional syntax) are rejected with SemanticCheckFailure.
Source
Thrown at botmaker/src/java/com/twitter/botmaker/compiler/types/StructTupleType.java:139
@Override
public Set<String> getFieldNames() {
Set<String> fNames = Sets.newHashSetWithExpectedSize(fieldNames.size() * 2);
fNames.addAll(fieldNames);
for (int i = 0; i < fieldNames.size(); ++i) {
fNames.add("_" + (i + 1));
}
return ImmutableSet.copyOf(fNames);
}
@Override
public Type getFieldType(String fieldName) throws SemanticCheckFailure {
int fieldIndex = fieldNames.indexOf(fieldName);
if (fieldIndex != -1) {
return fieldTypes.get(fieldIndex);
} else {
if (!fieldName.startsWith("_")) {
throw new SemanticCheckFailure(
String.format(
"field name %s is not found in struct tuple class %s",
fieldName,
toString()));
}
try {
return typeParams.get(Integer.valueOf(fieldName.substring(1)) - 1);
} catch (Throwable t) {
throw new SemanticCheckFailure(t);
}
}
}
@Override
public boolean isSetValue(StructTuple obj, String fieldName) {
if (fieldNames.contains(fieldName)) {View on GitHub (pinned to 24c60942c5)
Solutions
- Check fieldName against getFieldNames() (or use '_1', '_2' positional names) before calling getFieldType
- Fix the typo or use the renamed field from the current schema
- Confirm you are operating on the right class (tuple vs thrift struct)
Example fix
// before
type.getFieldType("usr_id"); // typo
// after
Set<String> names = type.getFieldNames(); // inspect, then
type.getFieldType("user_id"); Defensive patterns
Strategy: type-guard
Validate before calling
boolean ok = tuple.getFieldNames().contains(name) || name.matches("_\\d+")); Type guard
boolean isValidTupleField(StructTupleType t, String name) {
return t.getFieldNames().contains(name) || name.matches("_\\d+");
} Try / catch
catch SemanticCheckFailure and treat as a compile-time rule error; reject the rule with the offending name
Prevention
- Auto-complete field names from getFieldNames() in rule editors
- Lint rule fields against the deployed schema
When it happens
Trigger: Calling getFieldType(fieldName) with a name that is neither in the StructTuple's fieldNames list nor prefixed with '_' (e.g. a typo, a thrift field name used on a tuple class, or '_abc' style positional abuse reaching the non-numeric path).
Common situations: Rules written against thrift structs but executed on generated Tuple/StructTuple classes; field renames in the schema; copy-paste of field names with typos.
Related errors
- Field %s is not defined in thrift type %s
- field name %s is not an underscore followed by a number for
- type checking expression %s failed: invalid argument type: %
- Non-optional parameter %s must be declared before optional p
- Duplicated argument name %s
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/ce2e1004e74b07a3.
Report an issue: GitHub.