{"record":{"id":"4b9eaff8410865b8","repo":"xai-org/x-algorithm","slug":"s-cannnot-be-converted-to-s-missing-field-s","errorCode":null,"errorMessage":"%s cannnot be converted to %s. missing field %s.","messagePattern":"(.+?) cannnot be converted to (.+?)\\. missing field (.+?)\\.","errorType":"exception","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/types/StructTupleType.java","lineNumber":91,"sourceCode":"  @Override\n  public Type replaceTypeArguments(Map<Long, Type> mappedTypes) throws SemanticCheckFailure {\n    ImmutableList<Type> params = this.getTypeParams();\n    List<Type> inferredTypeParams = Lists.newArrayListWithCapacity(params.size());\n    for (Type typeParam : params) {\n      Type replacement = typeParam.replaceTypeArguments(mappedTypes);\n      inferredTypeParams.add(replacement);\n    }\n\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) -> {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/types/StructTupleType.java#L73-L109","documentation":"StructTupleType.converter builds an index map to convert one StructTuple layout into another. If the target StructTupleType declares a field name that does not exist in this type, conversion cannot proceed and SemanticCheckFailure is thrown.","triggerScenarios":"Calling converter(targetStructTupleType) where targetStructTupleType.fieldNames contains a name absent from this.fieldNames — e.g. joining or casting two struct tuples whose schemas were generated from different thrift structs.","commonSituations":"Schema drift: producer pipeline was regenerated with a new field while the botmaker rule still uses the old (or new) StructTuple class; using incompatible tuple classes after a thrift schema change.","solutions":["Regenerate/redeploy both StructTuple classes from the same thrift schema version so field sets match","Change the rule to convert to a StructTupleType whose field names are a subset of the source","Pre-check field coverage before calling converter"],"exampleFix":"// before\nFunction<StructTuple, StructTuple> f = srcType.converter(dstType); // dst has extra field\n// after\nboolean covers = srcType.getFieldNames().containsAll(dstType.getFieldNames());\nFunction<StructTuple, StructTuple> f = covers ? srcType.converter(dstType) : null;","handlingStrategy":"validation","validationCode":"Set<String> src = structTupleTypeA.getFieldNames();\nif (!src.containsAll(structTupleTypeB.getFieldNames())) {\n  throw new IllegalArgumentException(\"target has fields missing in source\");\n}","typeGuard":null,"tryCatchPattern":"catch SemanticCheckFailure around converter(); report the missing field name from the message to the rule author","preventionTips":["Keep StructTuple classes generated from a single schema version across pipelines","Assert field-set subset relation before conversions"],"tags":["struct-tuple","schema-validation","type-mismatch"],"backgroundTag":"schema-field-mismatch","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}