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

  1. Check fieldName against getFieldNames() (or use '_1', '_2' positional names) before calling getFieldType
  2. Fix the typo or use the renamed field from the current schema
  3. 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

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


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