apache/hadoop · error · InvalidObjectException
No type in deserialized FileStatus
Error message
No type in deserialized FileStatus
What it means
The second check in FileStatus.validateObject(): after Java-native deserialization, the isdir field (file-vs-directory flag) must be non-null or InvalidObjectException('No type in deserialized FileStatus') is thrown. A typeless FileStatus cannot answer isDirectory(), so the object is rejected rather than allowed to fail later.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java:545
* @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
- Replace Java serialization of FileStatus with path transfer + re-stat on the receiver
- Pin identical hadoop-common versions on both JVMs that exchange objects
- Use the protobuf Writable format (write/readFields) for binary transport instead
Example fix
// before objectOut.writeObject(fileStatus); FileStatus back = (FileStatus) objectIn.readObject(); // InvalidObjectException: no type // 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) {
// null isdir after deserialization - class shape mismatch; re-stat instead
FileStatus st = fileSystem.getFileStatus(knownPath);
} Prevention
- Avoid Java serialization for Hadoop Writable types
- Align hadoop-common versions on both sides of any object transfer
- Round-trip a canary object in tests to catch serialization drift early
When it happens
Trigger: ObjectInputStream.readObject() of FileStatus bytes from an incompatible class version where the isdir field did not survive, or a bare no-arg FileStatus serialized before any field was populated.
Common situations: Cross-version object shipping (Spark caching, replicated sessions) where one side runs an older/newer hadoop-common whose FileStatus fields differ.
Related errors
- No Path 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/3592fabe9e351f22.
Report an issue: GitHub.