{"record":{"id":"343464927e2a55c8","repo":"apache/hadoop","slug":"invalid-record-type-field","errorCode":null,"errorMessage":"invalid record type field: \"{}\"","messagePattern":"invalid record type field: \"(.+?)\"","errorType":"validation","errorClass":"InvalidRecordException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java","lineNumber":256,"sourceCode":"      results.add(new URL(address));\n    }\n    return results;\n  }\n\n  /**\n   * Validate the record by checking for null fields and other invalid\n   * conditions\n   * @param path path for exceptions\n   * @param record record to validate. May be null\n   * @throws InvalidRecordException on invalid entries\n   */\n  public static void validateServiceRecord(String path, ServiceRecord record)\n      throws InvalidRecordException {\n    if (record == null) {\n      throw new InvalidRecordException(path, \"Null record\");\n    }\n    if (!ServiceRecord.RECORD_TYPE.equals(record.type)) {\n      throw new InvalidRecordException(path,\n          \"invalid record type field: \\\"\" + record.type + \"\\\"\");\n    }\n\n    if (record.external != null) {\n      for (Endpoint endpoint : record.external) {\n        validateEndpoint(path, endpoint);\n      }\n    }\n    if (record.internal != null) {\n      for (Endpoint endpoint : record.internal) {\n        validateEndpoint(path, endpoint);\n      }\n    }\n  }\n\n  /**\n   * Validate the endpoint by checking for null fields and other invalid\n   * conditions","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java#L238-L274","documentation":"validateServiceRecord requires record.type to equal ServiceRecord.RECORD_TYPE ('JSONServiceRecord'); any other value throws InvalidRecordException ('invalid record type field: \"<actual>\"'). The type field is the self-describing marker telling readers the znode holds a marshalled ServiceRecord.","triggerScenarios":"A record whose type was overwritten (record.type = \"myrecord\"), deserialized JSON with a wrong or absent 'type' property (Jackson leaves it null), or a node written by an incompatible schema version.","commonSituations":"Custom record handling that changes the type string; hand-written JSON payloads in tests; version skew between writer and reader expecting different record types.","solutions":["Never mutate record.type — leave the default 'JSONServiceRecord' or restore it after deserialization","Fix the payload: re-marshal with JsonSerDeser.toBytes (which stamps the type) and re-register the record","Before validating, compare record.type to ServiceRecord.RECORD_TYPE and skip foreign-typed nodes with a clear message"],"exampleFix":"// before\nrecord.type = \"MyService\"; // custom type -> invalid record type field on validate\n\n// after\nrecord.type = ServiceRecord.RECORD_TYPE; // \"JSONServiceRecord\"","handlingStrategy":"validation","validationCode":"if (!ServiceRecord.RECORD_TYPE.equals(record.type)) {\n  throw new IllegalArgumentException(\n      \"Foreign record type at \" + path + \": expected \" + ServiceRecord.RECORD_TYPE\n      + \", got \" + record.type);\n}\nRegistryTypeUtils.validateServiceRecord(path, record);","typeGuard":"static boolean isServiceRecord(ServiceRecord record) {\n  return record != null && ServiceRecord.RECORD_TYPE.equals(record.type);\n}","tryCatchPattern":null,"preventionTips":["Never overwrite record.type — it must stay 'JSONServiceRecord'","Marshal records with JsonSerDeser.toBytes so the type field is stamped correctly","Reject foreign-typed nodes with a clear message before validation"],"tags":["registry","service-record","schema","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}