apache/hadoop · error · InvalidRecordException
invalid record type field: "{}"
Error message
invalid record type field: "{}" What it means
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.
Source
Thrown at hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java:256
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);
}
}
}
/**
* Validate the endpoint by checking for null fields and other invalid
* conditionsView on GitHub (pinned to 2add963021)
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
Example fix
// before record.type = "MyService"; // custom type -> invalid record type field on validate // after record.type = ServiceRecord.RECORD_TYPE; // "JSONServiceRecord"
Defensive patterns
Strategy: validation
Validate before calling
if (!ServiceRecord.RECORD_TYPE.equals(record.type)) {
throw new IllegalArgumentException(
"Foreign record type at " + path + ": expected " + ServiceRecord.RECORD_TYPE
+ ", got " + record.type);
}
RegistryTypeUtils.validateServiceRecord(path, record); Type guard
static boolean isServiceRecord(ServiceRecord record) {
return record != null && ServiceRecord.RECORD_TYPE.equals(record.type);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Custom record handling that changes the type string; hand-written JSON payloads in tests; version skew between writer and reader expecting different record types.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Null record
- No schema options are provided
- No codec option is provided
- No good option for numDataUnits or numParityUnits found
- Bad option value {} found for {}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/343464927e2a55c8.
Report an issue: GitHub.