{"record":{"id":"0f7bc2d3deb890b6","repo":"apache/hadoop","slug":"s-not-found-s","errorCode":null,"errorMessage":"%s not found: %s","messagePattern":"(.+?) not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-gcp/src/main/java/org/apache/hadoop/fs/gs/GoogleHadoopFileSystem.java","lineNumber":654,"sourceCode":"\n        return true;\n      },\n      String.format(\"mkdirs(%s)\", hadoopPath));\n  }\n\n  @Override\n  public FileStatus getFileStatus(final Path path) throws IOException {\n    return runOperation(\n      GcsStatistics.INVOCATION_GET_FILE_STATUS,\n      () -> {\n        checkArgument(path != null, \"path must not be null\");\n\n        checkOpen();\n\n        URI gcsPath = getGcsPath(path);\n        FileInfo fileInfo = getGcsFs().getFileInfo(gcsPath);\n        if (!fileInfo.exists()) {\n          throw new FileNotFoundException(\n                  String.format(\n                          \"%s not found: %s\", fileInfo.isDirectory() ? \"Directory\" : \"File\", path));\n        }\n        String userName = getUgiUserName();\n        return getFileStatus(fileInfo, userName);\n      },\n      String.format(\"getFileStatus(%s)\", path));\n  }\n\n  /**\n   * Returns home directory of the current user.\n   *\n   * <p>Note: This directory is only used for Hadoop purposes. It is not the same as a user's OS\n   * home directory.\n   */\n  @Override\n  public Path getHomeDirectory() {\n    Path result = new Path(fsRoot, \"user/\" + System.getProperty(\"user.name\"));","sourceCodeStart":636,"sourceCodeEnd":672,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-gcp/src/main/java/org/apache/hadoop/fs/gs/GoogleHadoopFileSystem.java#L636-L672","documentation":"GoogleHadoopFileSystem.getFileStatus throws FileNotFoundException(\"File|Directory not found: <path>\") when getGcsFs().getFileInfo(gcsPath) reports the item as non-existent. This follows standard Hadoop FileSystem semantics: stat on a missing path raises FileNotFoundException, prefixed with whether the path would have been a directory or file.","triggerScenarios":"fs.getFileStatus(new Path(\"gs://b/missing\")) for any absent object/directory; also TOCTOU where the object is deleted between a prior check and this call.","commonSituations":"Using getFileStatus for existence checks instead of fs.exists(); races with concurrent deleting/renaming jobs; wrong bucket or root prefix in constructed paths; missing GCS directory placeholders for 'empty' directories.","solutions":["Use fs.exists(path) when you only need existence.","Catch FileNotFoundException as the idiomatic 'missing' signal rather than pre-checking in concurrent environments.","Verify the path/bucket prefix construction if the object is expected to exist."],"exampleFix":"// before\nFileStatus st = fs.getFileStatus(new Path(\"gs://bucket/missing\")); // FileNotFoundException\n\n// after\nif (fs.exists(path)) {\n  FileStatus st = fs.getFileStatus(path);\n} else {\n  // handle missing path\n}","handlingStrategy":"try-catch","validationCode":"if (fs.exists(path)) {\n  FileStatus st = fs.getFileStatus(path);\n} else {\n  // handle missing path without exception\n}","typeGuard":null,"tryCatchPattern":"try {\n  FileStatus st = fs.getFileStatus(path);\n} catch (FileNotFoundException e) {\n  // idiomatic Hadoop 'missing' signal - do not wrap in generic error handling\n}","preventionTips":["Use fs.exists() for pure existence checks; reserve getFileStatus for when you need metadata.","In concurrent environments, catch FileNotFoundException instead of pre-checking to avoid TOCTOU."],"tags":["filestatus","gcs","hadoop","file-not-found","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}