{"record":{"id":"6c0479032eb33269","repo":"xai-org/x-algorithm","slug":"field-s-not-found-in-the-metadata-of-thrift-class","errorCode":null,"errorMessage":"field %s not found in the metadata of thrift class %s","messagePattern":"field (.+?) not found in the metadata of thrift class (.+?)","errorType":"exception","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/types/ThriftStructType.java","lineNumber":133,"sourceCode":"    return createType(typeBase, Function.exfunc0(() ->\n        new ThriftStructType(typeBase)\n    ));\n  }\n\n  @Override\n  public Set<String> getFieldNames() {\n    return metadataMap.keySet();\n  }\n\n  public FieldMetaData getFieldMetadata(String fieldName) {\n    return metadataMap.get(fieldName);\n  }\n\n  @Override\n  public Type getFieldType(String fieldName) throws SemanticCheckFailure {\n    FieldMetaData fieldMetaData = metadataMap.get(fieldName);\n    if (fieldMetaData == null) {\n      throw new SemanticCheckFailure(\n          String.format(\"field %s not found in the metadata of thrift class %s\",\n              fieldName, typeBase.getName()));\n    }\n\n    return fieldMetaData.valueMetaData.getType();\n  }\n\n  @SuppressWarnings(\"unchecked\")\n  @Override\n  public boolean isSetValue(ThriftStruct thriftObj, String fieldName) {\n    if (this.isUnion) {\n      ThriftUnion thriftUnion = (ThriftUnion) thriftObj;\n      Option<ThriftStructFieldInfo> fieldInfo = thriftUnion.unionStructFieldInfo();\n      if (fieldInfo.isEmpty()) {\n        return false;\n      } else {\n        return fieldInfo.get().tfield().name.equals(fieldName);\n      }","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/types/ThriftStructType.java#L115-L151","documentation":"ThriftStructType.getFieldType looks up a field in the class's thrift FieldMetaData map. A missing field means the scrooge-generated class has no such thrift field, and SemanticCheckFailure is raised.","triggerScenarios":"Calling getFieldType(fieldName) on a ThriftStructType where fieldName is not a thrift field of the underlying scrooge-generated struct (misspelled, renamed, or added after the class was compiled).","commonSituations":"Thrift schema renames/removes a field but botmaker rules still reference the old name; stale generated thrift classes on the classpath; rules written against a newer schema than deployed.","solutions":["Correct the field name to match the current thrift struct definition","Regenerate and redeploy the thrift classes matching the rule's schema version","List valid fields from metadataMap/getFieldNames before lookup"],"exampleFix":"// before\nthriftStructType.getFieldType(\"created_at\"); // field is 'createdAt'\n// after\nthriftStructType.getFieldType(\"createdAt\");","handlingStrategy":"type-guard","validationCode":"if (!thriftStructType.getFieldNames().contains(fieldName)) { ... }","typeGuard":"boolean hasField(ThriftStructType t, String f) { return t.getFieldNames().contains(f); }","tryCatchPattern":"catch SemanticCheckFailure; map to 'unknown field <name> on <class>' and fail rule validation early","preventionTips":["Validate all referenced fields once at rule load time","Keep IDL and rules in the same repo/CI pipeline"],"tags":["thrift","field-lookup","schema-validation"],"backgroundTag":"unknown-thrift-field","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}