{"record":{"id":"dafb255f31fd1393","repo":"apache/hadoop","slug":"no-path-in-deserialized-filestatus","errorCode":null,"errorMessage":"No Path in deserialized FileStatus","messagePattern":"No Path 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":542,"sourceCode":"  /**\n   * Write instance encoded as protobuf to stream.\n   * @param out Output stream\n   * @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":524,"sourceCodeEnd":552,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java#L524-L552","documentation":"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.","triggerScenarios":"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().","commonSituations":"Frameworks that Java-serialize objects containing FileStatus across JVMs (Spark RDD caching/shipping, session replication) with different hadoop-common versions on the two sides.","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"],"exampleFix":"// before\nobjectOut.writeObject(fileStatus);\nFileStatus back = (FileStatus) objectIn.readObject(); // InvalidObjectException\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  // incompatible serialized shape - recover by re-statting a known path\n  FileStatus st = fileSystem.getFileStatus(knownPath);\n}","preventionTips":["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"],"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-23T01:17:44.959Z"}