{"record":{"id":"8866c0b4c3a7a36f","repo":"apache/hadoop","slug":"null-record","errorCode":null,"errorMessage":"Null record","messagePattern":"Null record","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":253,"sourceCode":"    List<String> addresses = retrieveAddressesUriType(epr);\n    List<URL> results = new ArrayList<URL>(addresses.size());\n    for (String address : addresses) {\n      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","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java#L235-L271","documentation":"RegistryTypeUtils.validateServiceRecord(path, record) is the entry-point validator for ServiceRecords; a null record is invalid by definition and raises InvalidRecordException ('Null record') carrying the supplied path for context.","triggerScenarios":"Passing a null ServiceRecord into the validator — typically the result of a failed or absent fetch (a map.get(service) that returned null, or a read path that yields null) forwarded straight to validation.","commonSituations":"Validating a freshly deserialized record when the underlying read failed silently; service lookup code without a null check between fetch and validate.","solutions":["Check for null immediately after fetching the record and treat null as 'not found' instead of feeding it to the validator","Return Optional<ServiceRecord> from your lookup layer so nullability is explicit at the type level","Catch InvalidRecordException around validation and log the exception's path field to identify the offending registry node"],"exampleFix":"// before\nServiceRecord record = fetch(path); // returns null when absent\nRegistryTypeUtils.validateServiceRecord(path, record); // -> Null record\n\n// after\nServiceRecord record = fetch(path);\nif (record == null) {\n  return Optional.empty();\n}\nRegistryTypeUtils.validateServiceRecord(path, record);","handlingStrategy":"type-guard","validationCode":"if (record == null) {\n  return Optional.empty(); // no record at this path\n}\nRegistryTypeUtils.validateServiceRecord(path, record);","typeGuard":"static boolean isValidatableRecord(ServiceRecord record) {\n  return record != null;\n}","tryCatchPattern":"try {\n  RegistryTypeUtils.validateServiceRecord(path, record);\n} catch (InvalidRecordException e) {\n  LOG.warn(\"Bad record at {}: {}\", path, e.getMessage());\n  return Optional.empty();\n}","preventionTips":["Check fetch results for null before validating — null means 'not found', not 'invalid'","Model lookups as Optional<ServiceRecord> so nullability is explicit","Use the exception's path field to point at the offending registry node in logs"],"tags":["registry","service-record","null-check","validation"],"backgroundTag":"null-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}