{"record":{"id":"1e5661d45e8e3b46","repo":"apache/hadoop","slug":"key-no-such-file-or-directory","errorCode":null,"errorMessage":"key + \": No such file or directory.\"","messagePattern":"key \\+ \": No such file or directory\\.\"","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BosNativeFileSystemStore.java","lineNumber":351,"sourceCode":"   *\n   * @param key the object key\n   * @return the file checksum, or null if unavailable\n   * @throws IOException if the key does not exist or an I/O\n   *                     error occurs\n   */\n  public FileChecksum getFileChecksum(String key)\n      throws IOException {\n    try {\n      ObjectMetadata metadata =\n          bosClientProxy.getObjectMetadata(\n              bucketName, key);\n      if (metadata.getxBceCrc32c() == null) {\n        return null;\n      }\n      return new BosCRC32CCheckSum(\n          metadata.getxBceCrc32c());\n    } catch (FileNotFoundException e) {\n      throw new FileNotFoundException(\n          key + \": No such file or directory.\");\n    }\n  }\n\n  /**\n   * Checks whether the given key represents a directory.\n   *\n   * @param key the object key\n   * @return true if the key is a directory, false if it is a\n   *         file or does not exist\n   * @throws IOException if an I/O error occurs\n   */\n  public abstract boolean isDirectory(String key)\n      throws IOException;\n\n  /**\n   * Retrieves the metadata for the specified key.\n   *","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BosNativeFileSystemStore.java#L333-L369","documentation":"BosNativeFileSystemStore.getFileChecksum(key) HEADs the object to read its x-bce-crc32c metadata; a FileNotFoundException from that HEAD is rethrown as FileNotFoundException('<key>: No such file or directory.'). A present object without CRC32C metadata returns null instead — only a missing key produces this error.","triggerScenarios":"Calling FileSystem.getFileChecksum(path) on a key that does not exist: file deleted between listing and checksum call, or the path translates to a different key than intended (prefix/endpoint mismatch, double URI encoding).","commonSituations":"distcp with checksum comparison racing a concurrent delete or an in-flight write; Hive/Impala verification steps; keys containing characters that get re-encoded ('+', '%', spaces) so the HEAD targets a different key.","solutions":["Guard with exists()/getFileStatus() before getFileChecksum when the file may be gone","For distcp races, pass -skipcrccheck or retry the copy once the source/target is stable","If the file definitely exists, verify the path-to-key mapping: bucket endpoint, fs.bos prefix config, and URI encoding of special characters"],"exampleFix":"// before\nFileChecksum c = fs.getFileChecksum(path);\n\n// after\nif (!fs.exists(path)) {\n  throw new FileNotFoundException(path + \" already deleted\");\n}\nFileChecksum c = fs.getFileChecksum(path);","handlingStrategy":"validation","validationCode":"if (!fs.exists(path)) {\n  // handle absent file explicitly instead of calling getFileChecksum\n  return Optional.empty();\n}\nreturn Optional.of(fs.getFileChecksum(path));","typeGuard":null,"tryCatchPattern":"catch (FileNotFoundException e) {\n  // expected when files are deleted concurrently: skip or retry once\n  LOG.debug(\"file vanished before checksum: {}\", path);\n}","preventionTips":["Guard checksum calls with exists() when deletes are possible","Use -skipcrccheck in distcp for racy sources","Encode/normalize keys once at the boundary to avoid HEAD on a wrong key"],"tags":["bos","file-not-found","checksum","distcp","hadoop"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}