apache/hadoop · error · InvalidRecordException

Null record

Error message

Null record

What it means

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.

Source

Thrown at hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java:253

    List<String> addresses = retrieveAddressesUriType(epr);
    List<URL> results = new ArrayList<URL>(addresses.size());
    for (String address : addresses) {
      results.add(new URL(address));
    }
    return results;
  }

  /**
   * Validate the record by checking for null fields and other invalid
   * conditions
   * @param path path for exceptions
   * @param record record to validate. May be null
   * @throws InvalidRecordException on invalid entries
   */
  public static void validateServiceRecord(String path, ServiceRecord record)
      throws InvalidRecordException {
    if (record == null) {
      throw new InvalidRecordException(path, "Null record");
    }
    if (!ServiceRecord.RECORD_TYPE.equals(record.type)) {
      throw new InvalidRecordException(path,
          "invalid record type field: \"" + record.type + "\"");
    }

    if (record.external != null) {
      for (Endpoint endpoint : record.external) {
        validateEndpoint(path, endpoint);
      }
    }
    if (record.internal != null) {
      for (Endpoint endpoint : record.internal) {
        validateEndpoint(path, endpoint);
      }
    }
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Check for null immediately after fetching the record and treat null as 'not found' instead of feeding it to the validator
  2. Return Optional<ServiceRecord> from your lookup layer so nullability is explicit at the type level
  3. Catch InvalidRecordException around validation and log the exception's path field to identify the offending registry node

Example fix

// before
ServiceRecord record = fetch(path); // returns null when absent
RegistryTypeUtils.validateServiceRecord(path, record); // -> Null record

// after
ServiceRecord record = fetch(path);
if (record == null) {
  return Optional.empty();
}
RegistryTypeUtils.validateServiceRecord(path, record);
Defensive patterns

Strategy: type-guard

Validate before calling

if (record == null) {
  return Optional.empty(); // no record at this path
}
RegistryTypeUtils.validateServiceRecord(path, record);

Type guard

static boolean isValidatableRecord(ServiceRecord record) {
  return record != null;
}

Try / catch

try {
  RegistryTypeUtils.validateServiceRecord(path, record);
} catch (InvalidRecordException e) {
  LOG.warn("Bad record at {}: {}", path, e.getMessage());
  return Optional.empty();
}

Prevention

When it happens

Trigger: 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.

Common situations: Validating a freshly deserialized record when the underlying read failed silently; service lookup code without a null check between fetch and validate.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/8866c0b4c3a7a36f. Report an issue: GitHub.