{"record":{"id":"73ac467df08d5817","repo":"apache/hadoop","slug":"missing-pathhandle","errorCode":null,"errorMessage":"Missing PathHandle","messagePattern":"Missing PathHandle","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalFileSystemPathHandle.java","lineNumber":42,"sourceCode":"import java.util.Objects;\nimport java.util.Optional;\n\n/**\n * Opaque handle to an entity in a FileSystem.\n */\npublic class LocalFileSystemPathHandle implements PathHandle {\n\n  private final String path;\n  private final Long mtime;\n\n  public LocalFileSystemPathHandle(String path, Optional<Long> mtime) {\n    this.path = path;\n    this.mtime = mtime.orElse(null);\n  }\n\n  public LocalFileSystemPathHandle(ByteBuffer bytes) throws IOException {\n    if (null == bytes) {\n      throw new IOException(\"Missing PathHandle\");\n    }\n    LocalFileSystemPathHandleProto p =\n        LocalFileSystemPathHandleProto.parseFrom(ByteString.copyFrom(bytes));\n    path = p.hasPath()   ? p.getPath()  : null;\n    mtime = p.hasMtime() ? p.getMtime() : null;\n  }\n\n  public String getPath() {\n    return path;\n  }\n\n  public void verify(FileStatus stat) throws InvalidPathHandleException {\n    if (null == stat) {\n      throw new InvalidPathHandleException(\"Could not resolve handle\");\n    }\n    if (mtime != null && mtime != stat.getModificationTime()) {\n      throw new InvalidPathHandleException(\"Content changed\");\n    }","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalFileSystemPathHandle.java#L24-L60","documentation":"LocalFileSystemPathHandle is the PathHandle implementation for local files, serialized as protobuf bytes. The deserializing constructor demands a non-null ByteBuffer; passing null (no stored handle payload) throws this IOException before any parsing.","triggerScenarios":"new LocalFileSystemPathHandle((ByteBuffer) null), typically reached when a persisted handle field/metadata entry is empty and code feeds null bytes into handle deserialization instead of treating absence explicitly.","commonSituations":"Handle bytes never captured at write time, Optional.empty() handle representations forwarded as null, metadata schema where the handle column is nullable and unguarded.","solutions":["Null-check the byte buffer before deserializing and fail fast or skip with a clear message","Persist PathHandle.bytes() at capture time so stored handles are never null","Represent 'no handle' as Optional.empty()/absent in your model instead of null"],"exampleFix":"// before\nPathHandle h = new LocalFileSystemPathHandle(bytes);   // bytes == null\n// after\nif (bytes == null) throw new IOException(\"no PathHandle bytes stored\");\nPathHandle h = new LocalFileSystemPathHandle(bytes);","handlingStrategy":"validation","validationCode":"if (bytes == null) throw new IOException(\"no PathHandle bytes stored\");\nPathHandle h = new LocalFileSystemPathHandle(bytes);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always persist handle.bytes() when capturing a handle","Model absent handles as Optional<PathHandle>, never null","Guard deserialization entry points with null checks"],"tags":["path-handle","null-argument","serialization","local-filesystem"],"backgroundTag":"null-argument-validation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}