{"record":{"id":"7df60f946d917d9e","repo":"apache/hadoop","slug":"path-is-not-a-file-s","errorCode":null,"errorMessage":"Path is not a file, %s","messagePattern":"Path is not a file, (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/RawFileSystem.java","lineNumber":663,"sourceCode":"  public ObjectStorage storage() {\n    return storage;\n  }\n\n  public ExecutorService uploadThreadPool() {\n    return uploadThreadPool;\n  }\n\n  /**\n   * @return null if checksum is not supported.\n   */\n  @Override\n  public FileChecksum getFileChecksum(Path f, long length) throws IOException {\n    Preconditions.checkArgument(length >= 0);\n\n    RawFileStatus fileStatus = innerFileStatus(f);\n    if (fileStatus.isDirectory()) {\n      // Compatible with HDFS\n      throw new FileNotFoundException(String.format(\"Path is not a file, %s\", f));\n    }\n    if (!getConf().getBoolean(ConfKeys.FS_CHECKSUM_ENABLED.key(storage.scheme()),\n        ConfKeys.FS_CHECKSUM_ENABLED_DEFAULT)) {\n      return null;\n    }\n\n    ChecksumInfo csInfo = storage.checksumInfo();\n    return new TosChecksum(csInfo.algorithm(), fileStatus.checksum());\n  }\n\n  @Override\n  public String getCanonicalServiceName() {\n    return null;\n  }\n\n  @Override\n  public void setXAttr(Path path, String name, byte[] value, EnumSet<XAttrSetFlag> flag)\n      throws IOException {","sourceCodeStart":645,"sourceCodeEnd":681,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/RawFileSystem.java#L645-L681","documentation":"getFileChecksum(f, length) throws FileNotFoundException(\"Path is not a file, %s\") when the target is a directory. The comment notes this is for HDFS compatibility: HDFS also reports checksum requests on directories as FileNotFoundException rather than a type error.","triggerScenarios":"fs.getFileChecksum(dirPath, length) where innerFileStatus(dirPath).isDirectory() is true; also note length must be >= 0 (Preconditions.checkArgument) or you get IllegalArgumentException instead.","commonSituations":"Utilities that walk a tree and request checksums for every listStatus() entry without filtering; verification scripts assuming checksum failure means corruption hitting a directory entry; distcp-style compare steps.","solutions":["Filter to files before requesting checksums: skip entries where getFileStatus().isDirectory()","If checksums are disabled entirely (fs.tos.checksum.enabled=false) the call returns null for files -- treat that as 'no checksum', not an error","Pass a non-negative length"],"exampleFix":"// before\nfor (FileStatus st : fs.listStatus(dir)) {\n  FileChecksum cs = fs.getFileChecksum(st.getPath(), 1024); // throws on directories\n}\n\n// after\nfor (FileStatus st : fs.listStatus(dir)) {\n  if (!st.isDirectory()) { FileChecksum cs = fs.getFileChecksum(st.getPath(), 1024); }\n}","handlingStrategy":"validation","validationCode":"FileStatus st = fs.getFileStatus(f);\nif (!st.isFile()) return null; // HDFS parity: directories have no checksum\nFileChecksum cs = fs.getFileChecksum(f, Math.max(0, length));","typeGuard":null,"tryCatchPattern":"try { cs = fs.getFileChecksum(f, length); }\ncatch (FileNotFoundException e) {\n  if (fs.getFileStatus(f).isDirectory()) { /* skip dirs */ } else throw e;\n}","preventionTips":["Filter listStatus() results to files before checksumming","Treat null (checksums disabled) and directory-skip as normal outcomes","Pass a validated non-negative length"],"tags":["checksum","directory-mismatch","hdfs-parity","tos"],"backgroundTag":"path-is-not-a-file","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}