{"record":{"id":"e0fcaad8e1dda06c","repo":"xai-org/x-algorithm","slug":"field-s-is-not-defined-in-thrift-type-s","errorCode":null,"errorMessage":"Field %s is not defined in thrift type %s","messagePattern":"Field (.+?) is not defined in thrift type (.+?)","errorType":"exception","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/types/ThriftType.java","lineNumber":209,"sourceCode":"    TBase thriftObj = (TBase) typeBase.newInstance();\n    return thriftObj;\n  }\n\n  public TBase newInstance(Map<Object, Object> map) throws Exception {\n    TBase thriftObj = newInstance();\n    for (Map.Entry<Object, Object> entry : map.entrySet()) {\n      String fn = entry.getKey().toString();\n      setFieldValue(thriftObj, fn, entry.getValue());\n    }\n    return thriftObj;\n  }\n\n  @SuppressWarnings(\"unchecked\")\n  public void setFieldValue(\n      TBase thriftObj, String fieldName, Object fieldValue) throws Exception {\n    FieldMetaData metaData = metadataMap.get(fieldName);\n    if (metaData == null) {\n      throw new SemanticCheckFailure(\n          String.format(\"Field %s is not defined in thrift type %s\", fieldName, typeBase.getName())\n      );\n    }\n    Object value = extractFieldValue(metaData.valueMetaData, fieldValue, fieldName);\n    thriftObj.setFieldValue(thriftObj.fieldForId(metaData.fieldId), value);\n  }\n\n  private static Object getListFieldValue(FieldValueMetaData valueMetaData, Object fieldValue) {\n    ListMetaData listMetaData = (ListMetaData) valueMetaData;\n    FieldValueMetaData elemMetaData = listMetaData.elemMetaData;\n    if (!isConversionRequired(elemMetaData)) {\n      return fieldValue;\n    }\n\n    ImmutableList.Builder<Object> builder = ImmutableList.builder();\n    for (Object val : (Collection) fieldValue) {\n      Object converted = getFieldValue(elemMetaData, val);\n      builder.add(converted);","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/types/ThriftType.java#L191-L227","documentation":"ThriftType.setFieldValue writes a value onto a TBase object by looking up fieldName in the thrift metadata. If the field is not defined, SemanticCheckFailure 'Field %s is not defined in thrift type %s' is thrown before any assignment.","triggerScenarios":"Calling setFieldValue(obj, fieldName, value) (often from newInstance when building default records) with a fieldName absent from the TBase class's FieldMetaData.","commonSituations":"Constructing default/example records from config that names fields removed by a schema change; environment mismatch where one service's rules reference fields another's thrift jar lacks.","solutions":["Validate fieldName against getFieldNames()/metadataMap before setting","Fix or remove stale field names in the rule/config","Deploy matching generated thrift classes"],"exampleFix":"// before\nthriftType.setFieldValue(rec, \"oldField\", v);\n// after\nif (thriftType.getFieldNames().contains(\"newField\")) {\n  thriftType.setFieldValue(rec, \"newField\", v);\n}","handlingStrategy":"validation","validationCode":"if (!thriftType.getFieldNames().contains(fieldName)) {\n  throw new IllegalArgumentException(\"field not in thrift type\");\n}","typeGuard":null,"tryCatchPattern":"catch SemanticCheckFailure around setFieldValue/newInstance; log field name and typeBase","preventionTips":["Validate default-record configs against the thrift schema in CI","Keep example records in schema-checked fixtures"],"tags":["thrift","field-lookup","validation"],"backgroundTag":"unknown-thrift-field","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}