{"record":{"id":"3592fabe9e351f22","repo":"apache/hadoop","slug":"no-type-in-deserialized-filestatus","errorCode":null,"errorMessage":"No type in deserialized FileStatus","messagePattern":"No type in deserialized FileStatus","errorType":"validation","errorClass":"InvalidObjectException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java","lineNumber":545,"sourceCode":"   * @see PBHelper#convert(FileStatus)\n   * @deprecated Use the {@link PBHelper} and protobuf serialization directly.\n   */\n  @Override\n  @Deprecated\n  public void write(DataOutput out) throws IOException {\n    FileStatusProto proto = PBHelper.convert(this);\n    int size = proto.getSerializedSize();\n    out.writeInt(size);\n    out.write(proto.toByteArray());\n  }\n\n  @Override\n  public void validateObject() throws InvalidObjectException {\n    if (null == path) {\n      throw new InvalidObjectException(\"No Path in deserialized FileStatus\");\n    }\n    if (null == isdir) {\n      throw new InvalidObjectException(\"No type in deserialized FileStatus\");\n    }\n  }\n\n\n\n}\n","sourceCodeStart":527,"sourceCodeEnd":552,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java#L527-L552","documentation":"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.","triggerScenarios":"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.","commonSituations":"Cross-version object shipping (Spark caching, replicated sessions) where one side runs an older/newer hadoop-common whose FileStatus fields differ.","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"],"exampleFix":"// before\nobjectOut.writeObject(fileStatus);\nFileStatus back = (FileStatus) objectIn.readObject(); // InvalidObjectException: no type\n\n// after: ship the path, re-stat remotely\nobjectOut.writeUTF(fileStatus.getPath().toString());\n// receiver:\nFileStatus back = fileSystem.getFileStatus(new Path(objectIn.readUTF()));","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  FileStatus st = (FileStatus) objectIn.readObject();\n} catch (InvalidObjectException e) {\n  // null isdir after deserialization - class shape mismatch; re-stat instead\n  FileStatus st = fileSystem.getFileStatus(knownPath);\n}","preventionTips":["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"],"tags":["hadoop","java-serialization","filestatus","invalid-object"],"backgroundTag":"java-deserialization-validation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}