{"record":{"id":"5a5c2d9f4a321e5e","repo":"apache/hadoop","slug":"file-does-not-exist-in-pseudo-local-file-system","errorCode":null,"errorMessage":"File {} does not exist in pseudo local file system","messagePattern":"File (.+?) does not exist in pseudo local file system","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/PseudoLocalFs.java","lineNumber":134,"sourceCode":"   * @throws FileNotFoundException\n   */\n  long validateFileNameFormat(Path path) throws FileNotFoundException {\n    path = this.makeQualified(path);\n    boolean valid = true;\n    long fileSize = 0;\n    if (!path.toUri().getScheme().equals(getUri().getScheme())) {\n      valid = false;\n    } else {\n      String[] parts = path.toUri().getPath().split(\"\\\\.\");\n      try {\n        fileSize = Long.parseLong(parts[parts.length - 1]);\n        valid = (fileSize >= 0);\n      } catch (NumberFormatException e) {\n        valid = false;\n      }\n    }\n    if (!valid) {\n      throw new FileNotFoundException(\"File \" + path\n          + \" does not exist in pseudo local file system\");\n    }\n    return fileSize;\n  }\n\n  /**\n   * @See create(Path) for details\n   */\n  @Override\n  public FSDataInputStream open(Path path, int bufferSize) throws IOException {\n    long fileSize = validateFileNameFormat(path);\n    InputStream in = new RandomInputStream(fileSize, bufferSize);\n    return new FSDataInputStream(in);\n  }\n\n  /**\n   * @See create(Path) for details\n   */","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/PseudoLocalFs.java#L116-L152","documentation":"Thrown by PseudoLocalFs.validateFileNameFormat() when a path is not a valid pseudo-local file name. PseudoLocalFs is a virtual, read-only FileSystem used by gridmix that generates random data on the fly; every file URI must look like pseudo:///<name>.<fileSize> where the last dot-separated segment is a non-negative long giving the file size in bytes. The check fails when the URI scheme is not 'pseudo' or when Long.parseLong() of the last '.'-segment throws NumberFormatException or yields a negative value.","triggerScenarios":"Calling open(path), getFileStatus(path), or create(path) on a PseudoLocalFs instance with: (1) a path whose last '.'-separated component is not a number (e.g. pseudo:///input.txt), (2) a negative size suffix (pseudo:///f.-5), (3) a path qualified with a different scheme (file:///f.1024) after makeQualified(), or (4) a path with no dot at all, where split returns the whole name and parse fails.","commonSituations":"Building gridmix/DistributedCacheEmulator input paths by hand instead of using PseudoLocalFs.generateFilePath(fileId, fileSize); passing raw job-trace paths into code that expects pseudo-local files; forgetting the '.<bytes>' size suffix; copying a plain filename from another FileSystem into pseudo:///. Also thrown (wrapped as 'File creation failed for <path>') from create().","solutions":["Format the path as <uniqueName>.<sizeInBytes> (e.g. pseudo:///file0.1048576), or better, call PseudoLocalFs.generateFilePath(fileId, fileSize) which builds the correct relative path","Make sure the path is qualified with the pseudo:// scheme that PseudoLocalFs.getUri() returns (URI.create(\"pseudo:///\"))","Verify the size suffix is a non-negative long before opening; validate with the same split(\"\\\\.\") + Long.parseLong logic","If you intended a real file, use the local FileSystem or HDFS instead of PseudoLocalFs"],"exampleFix":"// before\nPath p = new Path(\"pseudo:///part-00000\");\nfs.open(p); // FileNotFoundException: no size suffix\n\n// after\nPath p = PseudoLocalFs.generateFilePath(\"part-00000\", 1024L * 1024L);\n// => pseudo:///part-00000.1048576\nfs.open(p);","handlingStrategy":"validation","validationCode":"// Validate a pseudo-local path before open()\nstatic long pseudoFileSize(Path p) {\n  if (!\"pseudo\".equals(p.toUri().getScheme())) {\n    throw new IllegalArgumentException(\"Not a pseudo:// path: \" + p);\n  }\n  String[] parts = p.toUri().getPath().split(\"\\\\.\");\n  long size = Long.parseLong(parts[parts.length - 1]);\n  if (size < 0) throw new IllegalArgumentException(\"Negative size: \" + p);\n  return size;\n}\n// Or simply build paths only via PseudoLocalFs.generateFilePath(fileId, size)","typeGuard":null,"tryCatchPattern":"try {\n  fs.open(path);\n} catch (FileNotFoundException e) {\n  // path failed pseudo-local naming rules: scheme != pseudo or missing .<size> suffix\n  LOG.warn(\"Invalid pseudo-local path {}\", path, e);\n}","preventionTips":["Always construct pseudo-local paths with PseudoLocalFs.generateFilePath(fileId, fileSize) instead of string concatenation","Keep the '.<bytes>' suffix invariant in code review checklists for anything touching pseudo:///","Fully qualify pseudo-local URIs with the pseudo:// scheme before passing them across components"],"tags":["hadoop","gridmix","pseudo-local-fs","file-not-found","path-validation"],"backgroundTag":"invalid-file-path-format","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}