{"record":{"id":"bc07684e686bd148","repo":"apache/iceberg","slug":"file-does-not-exist-s","errorCode":null,"errorMessage":"File does not exist: %s","messagePattern":"File does not exist: (.+?)","errorType":"exception","errorClass":"NotFoundException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/hadoop/HadoopInputFile.java","lineNumber":166,"sourceCode":"    this.conf = conf;\n    this.length = length;\n  }\n\n  private HadoopInputFile(FileSystem fs, FileStatus stat, Configuration conf) {\n    this.fs = fs;\n    this.path = stat.getPath();\n    this.location = path.toString();\n    this.stat = stat;\n    this.conf = conf;\n    this.length = stat.getLen();\n  }\n\n  private FileStatus lazyStat() {\n    if (stat == null) {\n      try {\n        this.stat = fs.getFileStatus(path);\n      } catch (FileNotFoundException e) {\n        throw new NotFoundException(e, \"File does not exist: %s\", path);\n      } catch (IOException e) {\n        throw new RuntimeIOException(e, \"Failed to get status for file: %s\", path);\n      }\n    }\n    return stat;\n  }\n\n  @Override\n  public long getLength() {\n    if (length == null) {\n      this.length = lazyStat().getLen();\n    }\n    return length;\n  }\n\n  @Override\n  public SeekableInputStream newStream() {\n    try {","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/hadoop/HadoopInputFile.java#L148-L184","documentation":"HadoopInputFile caches a FileStatus lazily via lazyStat(). If fs.getFileStatus throws FileNotFoundException — the file does not exist at the given path — it is rethrown as a NotFoundException with the path. This is the Iceberg way of surfacing a missing data/metadata file during reads.","triggerScenarios":"Calling getLength(), getStat(), or exists() on a HadoopInputFile whose path was deleted, never written, has a typo, or whose authority/scheme resolves to the wrong filesystem; reading a table whose manifest/data files were removed by retention cleanup.","commonSituations":"Table metadata pointing to files deleted by expireSnapshots or orphan-file cleanup; wrong fs.defaultFS or warehouse path so relative paths resolve elsewhere; object-store eventual consistency on aggressively tuned S3 clients.","solutions":["Check the path in the exception and verify the file exists on the target filesystem.","Verify table metadata is current: refresh the table and retry the scan.","Confirm fs.defaultFS / scheme / authority configuration matches the cluster that wrote the files.","Restore accidentally deleted files from backup or roll back the snapshot; disable concurrent cleanup jobs racing with reads.","If files legitimately vanished, rewrite metadata or use Iceberg rollback to a snapshot whose files still exist."],"exampleFix":"// before\nInputFile f = io.newInputFile(\"s3://bucket/warehouse/db/t/metadata/old.avro\");\nlong len = f.getLength(); // throws NotFoundException\n// after\nInputFile f = io.newInputFile(path);\nif (f.exists()) {\n  long len = f.getLength();\n} else {\n  table.refresh(); // pick up newer metadata\n}","handlingStrategy":"try-catch","validationCode":"InputFile f = io.newInputFile(path);\nif (f.exists()) { /* safe to read */ }","typeGuard":"boolean readable = io.newInputFile(path).exists();","tryCatchPattern":"try {\n  InputFile f = io.newInputFile(path);\n  long len = f.getLength();\n} catch (NotFoundException e) {\n  // file missing: refresh table metadata or restore file\n}","preventionTips":["Refresh tables before scans to avoid stale metadata referencing deleted files.","Keep snapshot expiration retention long enough for active readers.","Align fs.defaultFS and path authorities with the cluster that wrote the data.","Don't run orphan-file cleanup concurrently with readers."],"tags":["not-found","file-io","hadoop","input-file"],"backgroundTag":"file-not-found","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}