apache/hadoop · error · InvalidObjectException
No Path in deserialized FileStatus
Error message
No Path in deserialized FileStatus
What it means
FileStatus implements ObjectInputValidation: after Java-native deserialization, validateObject() runs and throws InvalidObjectException when the path field is null. A FileStatus without a path is unusable, so the guard marks the deserialized bytes as incompatible (different class shape) or the object as never properly initialized.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java:542
/**
* Write instance encoded as protobuf to stream.
* @param out Output stream
* @see PBHelper#convert(FileStatus)
* @deprecated Use the {@link PBHelper} and protobuf serialization directly.
*/
@Override
@Deprecated
public void write(DataOutput out) throws IOException {
FileStatusProto proto = PBHelper.convert(this);
int size = proto.getSerializedSize();
out.writeInt(size);
out.write(proto.toByteArray());
}
@Override
public void validateObject() throws InvalidObjectException {
if (null == path) {
throw new InvalidObjectException("No Path in deserialized FileStatus");
}
if (null == isdir) {
throw new InvalidObjectException("No type in deserialized FileStatus");
}
}
}
View on GitHub (pinned to 2add963021)
Solutions
- Stop Java-serializing FileStatus: send path.toString() and re-stat on the receiver via fs.getFileStatus(new Path(s))
- Align hadoop-common versions on producer and consumer so the serialized class shape matches
- If binary transfer is required, use the Writable format (write/readFields) or FileStatusProto instead of native serialization
Example fix
// before objectOut.writeObject(fileStatus); FileStatus back = (FileStatus) objectIn.readObject(); // InvalidObjectException // after: ship the path, re-stat remotely objectOut.writeUTF(fileStatus.getPath().toString()); // receiver: FileStatus back = fileSystem.getFileStatus(new Path(objectIn.readUTF()));
Defensive patterns
Strategy: try-catch
Try / catch
try {
FileStatus st = (FileStatus) objectIn.readObject();
} catch (InvalidObjectException e) {
// incompatible serialized shape - recover by re-statting a known path
FileStatus st = fileSystem.getFileStatus(knownPath);
} Prevention
- Never persist or ship FileStatus via Java native serialization
- Keep Hadoop versions identical across JVMs that exchange objects
- Transfer the Path string or protobuf form and re-stat on the receiving side
When it happens
Trigger: ObjectInputStream.readObject() on FileStatus bytes whose serialized form lacks the path field (producer/consumer Hadoop version mismatch), or round-tripping a FileStatus built with the no-arg constructor and never populated via set()/readFields().
Common situations: Frameworks that Java-serialize objects containing FileStatus across JVMs (Spark RDD caching/shipping, session replication) with different hadoop-common versions on the two sides.
Related errors
- No type in deserialized FileStatus
- %s not found: %s
- Can't read FileStatusProto with negative size of ${size}
- Path must be absolute: " + path
- Append is not supported by BaiduBosFileSystem
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/dafb255f31fd1393.
Report an issue: GitHub.