apache/hadoop · error · NoRecordException
Data at path too short
Error message
Data at path too short
What it means
fromBytes(path, bytes, marker) requires the payload to be at least as long as the expected marker string (for registry ServiceRecords the marker is 'JSONServiceRecord'). A non-empty payload shorter than the marker cannot possibly be a record, so it throws NoRecordException with 'Data at path too short'.
Source
Thrown at hadoop-common-project/hadoop-registry/src/main/java/org/apache/hadoop/registry/client/binding/JsonSerDeser.java:103
* @param path path the data came from
* @param bytes byte array
* @param marker an optional string which, if set, MUST be present in the
* UTF-8 parsed payload.
* @return The parsed record
* @throws IOException all problems
* @throws EOFException not enough data
* @throws InvalidRecordException if the JSON parsing failed.
* @throws NoRecordException if the data is not considered a record: either
* it is too short or it did not contain the marker string.
*/
public T fromBytes(String path, byte[] bytes, String marker)
throws IOException {
int len = bytes.length;
if (len == 0 ) {
throw new NoRecordException(path, E_NO_DATA);
}
if (StringUtils.isNotEmpty(marker) && len < marker.length()) {
throw new NoRecordException(path, E_DATA_TOO_SHORT);
}
String json = new String(bytes, 0, len, StandardCharsets.UTF_8);
if (StringUtils.isNotEmpty(marker)
&& !json.contains(marker)) {
throw new NoRecordException(path, E_MISSING_MARKER_STRING + marker);
}
try {
return fromJson(json);
} catch (JsonProcessingException e) {
throw new InvalidRecordException(path, e.toString(), e);
}
}
}
View on GitHub (pinned to 2add963021)
Solutions
- Store plain values (counters, flags) in a separate subtree and never read them through fromBytes with a marker
- Rewrite the node with a complete marshalled record (JsonSerDeser.toBytes) rather than patching bytes by hand
- Guard reads by size: skip nodes whose stat.size is not greater than the marker length (RegistryUtils checks stat.size > ServiceRecord.RECORD_TYPE.length())
Example fix
// before
ServiceRecord r = marshal.fromBytes(path, zkGetData(path), ServiceRecord.RECORD_TYPE); // node holds "1"
// after
Stat s = registryOps.stat(path);
if (s == null || s.getDataLength() <= ServiceRecord.RECORD_TYPE.length()) {
return Optional.empty(); // not a record node
}
ServiceRecord r = marshal.fromBytes(path, zkGetData(path), ServiceRecord.RECORD_TYPE); Defensive patterns
Strategy: validation
Validate before calling
Stat stat = registryOps.stat(path);
if (stat == null || stat.getDataLength() <= marker.length()) {
return Optional.empty(); // too short to be a record — same guard RegistryUtils uses
}
return Optional.of(marshal.fromBytes(path, zkGetData(path), marker)); Try / catch
try {
return Optional.of(marshal.fromBytes(path, bytes, marker));
} catch (NoRecordException e) {
return Optional.empty(); // covers 'Data at path too short'
} Prevention
- Never store counters/flags in nodes that will be read as records — use a separate subtree
- Write records in one atomic ZooKeeper operation so truncation cannot occur
- Use RegistryUtils-style size guards (stat.size > marker length) before record reads
When it happens
Trigger: A znode holding a few bytes of non-record data — an epoch counter, a flag like '1', leftover test data — being read as a ServiceRecord; or a truncated write from a publisher that crashed mid-operation.
Common situations: Mixing record nodes and plain utility nodes under the same registry subtree; partial writes after connection loss to ZooKeeper; manual znode edits with short placeholder values.
Related errors
- No data at path
- Missing marker string: %s
- Invalid Path "%s" : %s
- No parent of %s
- Service {} is in wrong state: {}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/8c91daf49b3aabc0.
Report an issue: GitHub.