{"record":{"id":"9a5779722f70ea33","repo":"xai-org/x-algorithm","slug":"s-cannnot-be-converted-to-s-field-type-s-misma","errorCode":null,"errorMessage":"%s cannnot be converted to %s. field type %s mismatch.","messagePattern":"(.+?) cannnot be converted to (.+?)\\. field type (.+?) mismatch\\.","errorType":"exception","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/types/StructTupleType.java","lineNumber":99,"sourceCode":"\n    return ofStructTuple(fieldNames, ImmutableList.copyOf(inferredTypeParams));\n  }\n\n  public Function<StructTuple, StructTuple> converter(\n      StructTupleType structTupleType) throws SemanticCheckFailure {\n    int[] indexMap = new int[structTupleType.fieldNames.size()];\n    for (int i = 0; i < structTupleType.fieldNames.size(); i++) {\n      int fi = fieldNames.indexOf(structTupleType.fieldNames.get(i));\n      if (fi < 0) {\n        throw new SemanticCheckFailure(\n            String.format(\"%s cannnot be converted to %s. missing field %s.\",\n                this,\n                structTupleType,\n                structTupleType.fieldNames.get(i))\n        );\n      }\n      if (!fieldTypes.get(fi).equals(structTupleType.fieldTypes.get(i))) {\n        throw new SemanticCheckFailure(\n            String.format(\"%s cannnot be converted to %s. field type %s mismatch.\",\n                this,\n                structTupleType,\n                structTupleType.fieldNames.get(i))\n        );\n      }\n      indexMap[i] = fi;\n    }\n\n    return Function.func((StructTuple t) -> {\n      List<Object> fieldValues = Lists.newArrayListWithCapacity(indexMap.length);\n      for (int i = 0; i < indexMap.length; i++) {\n        fieldValues.add(t.get(indexMap[i]));\n      }\n      return StructTuple.of(\n          structTupleType.fieldNames,\n          fieldValues\n      );","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/types/StructTupleType.java#L81-L117","documentation":"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.","triggerScenarios":"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.","commonSituations":"Thrift schema evolution changing a field's type (int32 -> int64), mixed thrift class versions across services, hand-edited StructTuple definitions.","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"],"exampleFix":"// before\nsrcType.converter(dstType); // field 'id' is LONG in src, INT in dst\n// after\n// regenerate dst from the same schema so 'id' is LONG in both, then:\nsrcType.converter(dstType);","handlingStrategy":"validation","validationCode":"for (String f : dst.getFieldNames()) {\n  if (!src.getFieldType(f).equals(dst.getFieldType(f))) {\n    throw new IllegalArgumentException(\"type mismatch on \" + f);\n  }\n}","typeGuard":null,"tryCatchPattern":"catch SemanticCheckFailure; surface field name and both types to guide schema realignment","preventionTips":["Regenerate all tuple classes together after schema changes","Never hand-edit generated StructTuple field types"],"tags":["struct-tuple","type-mismatch","schema-validation"],"backgroundTag":"schema-field-type-mismatch","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}