xai-org/x-algorithm · error · SemanticCheckFailure
cannnot be converted to . field type mismatch.
Error message
%s cannnot be converted to %s. field type %s mismatch.
What it means
During StructTuple conversion, every shared field name must have an identical field Type on both sides. If fieldTypes differ for the same field index, the converter aborts with SemanticCheckFailure.
Solutions
- Align the field types by regenerating both tuple classes from the same schema
- Add an explicit cast/projection in the rule so both sides agree on type
- Verify types with getFieldType on both sides before converting
Example fix
// before srcType.converter(dstType); // field 'id' is LONG in src, INT in dst // after // regenerate dst from the same schema so 'id' is LONG in both, then: srcType.converter(dstType);
Defensive patterns
Strategy: validation
Validate before calling
for (String f : dst.getFieldNames()) {
if (!src.getFieldType(f).equals(dst.getFieldType(f))) {
throw new IllegalArgumentException("type mismatch on " + f);
}
} Try / catch
catch SemanticCheckFailure; surface field name and both types to guide schema realignment
Prevention
- Regenerate all tuple classes together after schema changes
- Never hand-edit generated StructTuple field types
When it happens
Trigger: converter(target) where a field exists in both StructTupleTypes but with different Types, e.g. LONG vs INT, or a nested struct type regenerated with different parameters.
Common situations: Thrift schema evolution changing a field's type (int32 -> int64), mixed thrift class versions across services, hand-edited StructTuple definitions.
Related errors
- cannnot be converted to . missing field .
- field expects type but received.
- StructTuple field expects type , but received.
- Cannot create StructTuple Type without a fieldName list.
- Class is not assignable from for field
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/9a5779722f70ea33.
Report an issue: GitHub.
Appendix: source
Thrown at botmaker/src/java/com/twitter/botmaker/compiler/types/StructTupleType.java:99
return ofStructTuple(fieldNames, ImmutableList.copyOf(inferredTypeParams));
}
public Function<StructTuple, StructTuple> converter(
StructTupleType structTupleType) throws SemanticCheckFailure {
int[] indexMap = new int[structTupleType.fieldNames.size()];
for (int i = 0; i < structTupleType.fieldNames.size(); i++) {
int fi = fieldNames.indexOf(structTupleType.fieldNames.get(i));
if (fi < 0) {
throw new SemanticCheckFailure(
String.format("%s cannnot be converted to %s. missing field %s.",
this,
structTupleType,
structTupleType.fieldNames.get(i))
);
}
if (!fieldTypes.get(fi).equals(structTupleType.fieldTypes.get(i))) {
throw new SemanticCheckFailure(
String.format("%s cannnot be converted to %s. field type %s mismatch.",
this,
structTupleType,
structTupleType.fieldNames.get(i))
);
}
indexMap[i] = fi;
}
return Function.func((StructTuple t) -> {
List<Object> fieldValues = Lists.newArrayListWithCapacity(indexMap.length);
for (int i = 0; i < indexMap.length; i++) {
fieldValues.add(t.get(indexMap[i]));
}
return StructTuple.of(
structTupleType.fieldNames,
fieldValues
);View on GitHub (pinned to 24c60942c5)