{"record":{"id":"857d70fdf1c9ceee","repo":"apache/iceberg","slug":"failed-to-open-file-s-857d70","errorCode":null,"errorMessage":"Failed to open file: %s","messagePattern":"Failed to open file: (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"orc/src/main/java/org/apache/iceberg/orc/ORC.java","lineNumber":808,"sourceCode":"          batchedReaderFunc,\n          recordsPerBatch);\n    }\n  }\n\n  static Reader newFileReader(InputFile file, Configuration config) {\n    ReaderOptions readerOptions = OrcFile.readerOptions(config).useUTCTimestamp(true);\n    if (file instanceof HadoopInputFile) {\n      readerOptions.filesystem(((HadoopInputFile) file).getFileSystem());\n    } else {\n      // In case of any other InputFile we wrap the InputFile with InputFileSystem that only\n      // supports the creation of an InputStream. To prevent a file status call to determine the\n      // length we supply the length as input\n      readerOptions.filesystem(new FileIOFSUtil.InputFileSystem(file)).maxLength(file.getLength());\n    }\n    try {\n      return OrcFile.createReader(new Path(file.location()), readerOptions);\n    } catch (IOException ioe) {\n      throw new RuntimeIOException(ioe, \"Failed to open file: %s\", file.location());\n    }\n  }\n\n  static Writer newFileWriter(\n      OutputFile file, OrcFile.WriterOptions options, Map<String, byte[]> metadata) {\n    if (file instanceof HadoopOutputFile) {\n      options.fileSystem(((HadoopOutputFile) file).getFileSystem());\n    } else {\n      options.fileSystem(new FileIOFSUtil.OutputFileSystem(file));\n    }\n    final Path locPath = new Path(file.location());\n    final Writer writer;\n\n    try {\n      writer = OrcFile.createWriter(locPath, options);\n    } catch (IOException ioe) {\n      throw new RuntimeIOException(ioe, \"Can't create file %s\", locPath);\n    }","sourceCodeStart":790,"sourceCodeEnd":826,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/orc/src/main/java/org/apache/iceberg/orc/ORC.java#L790-L826","documentation":"ORC.read(file) opens an ORC file via OrcFile.createReader with the configured reader options. If an IOException occurs during open (missing file, corrupt footer, filesystem/network errors), it is rethrown as RuntimeIOException with 'Failed to open file: <location>'.","triggerScenarios":"ORC.read(...) or internal reader construction on a file whose location cannot be read: file deleted, wrong path/URI, no permissions, network/filesystem outage, corrupted ORC footer.","commonSituations":"Files removed by retention cleanup while a scan is running; wrong filesystem credentials or missing Hadoop/S3 configuration; truncated/corrupt ORC files; typo in file URI scheme.","solutions":["Verify the file exists and is readable at the reported location (check FileIO, credentials, filesystem config)","Check that the file's ORC footer is intact (file not truncated by a failed write)","Retry if the failure was transient (network/filesystem hiccup)","Fix the file URI/scheme and path construction"],"exampleFix":"// before\nReader reader = ORC.read(file.io().newInputFile(\"s3://bucket/missing.orc\")).build();\n// after\nInputFile f = file.io().newInputFile(location);\nif (!f.exists()) { log.warn(\"Skipping missing ORC file {}\", location); return; }\nReader reader = ORC.read(f).build();","handlingStrategy":"try-catch","validationCode":"InputFile f = io.newInputFile(location);\nif (!f.exists()) { throw new FileNotFoundException(location); }\ntry (CloseableInputStream in = f.newStream()) { in.read(); } // probe readability","typeGuard":null,"tryCatchPattern":"try {\n  Reader reader = ORC.read(inputFile).build();\n} catch (RuntimeIOException e) {\n  if (e.getMessage().startsWith(\"Failed to open file\")) {\n    log.error(\"ORC file unreadable at {}: {}\", inputFile.location(), e.getCause());\n    throw new SkipCorruptFileException(inputFile.location(), e);\n  } throw e;\n}","preventionTips":["Confirm FileIO credentials and filesystem config before scans","Avoid deleting files while concurrent readers may access them (retention policies)","Validate ORC file integrity after failed/interrupted writes","Use correct URI schemes in file locations"],"tags":["orc","io","file-open","filesystem"],"backgroundTag":"file-open-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}