{"record":{"id":"5ddd95cdf7f679d5","repo":"apache/iceberg","slug":"failed-to-open-file-s","errorCode":null,"errorMessage":"Failed to open file: %s","messagePattern":"Failed to open file: (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/avro/AvroIterable.java","lineNumber":113,"sourceCode":"    }\n\n    return CloseableIterator.withClose(fileReader);\n  }\n\n  private DataFileReader<D> newFileReader() {\n    SeekableInput stream = null;\n    try {\n      stream = AvroIO.stream(file.newStream(), file.getLength());\n      return (DataFileReader<D>) DataFileReader.openReader(stream, reader);\n    } catch (IOException e) {\n      if (stream != null) {\n        try {\n          stream.close();\n        } catch (IOException closeException) {\n          // Ignore close exception\n        }\n      }\n      throw new RuntimeIOException(e, \"Failed to open file: %s\", file.location());\n    }\n  }\n\n  private static class AvroRangeIterator<D> implements FileReader<D> {\n    private final FileReader<D> reader;\n    private final long end;\n\n    AvroRangeIterator(FileReader<D> reader, long start, long end) {\n      this.reader = reader;\n      this.end = end;\n\n      try {\n        reader.sync(start);\n      } catch (IOException e) {\n        throw new RuntimeIOException(e, \"Failed to find sync past position %d\", start);\n      }\n    }\n","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/avro/AvroIterable.java#L95-L131","documentation":"AvroIterable.newFileReader opens the underlying InputFile and constructs the Avro DataFileReader. Any failure while creating the stream or initializing the Avro reader is wrapped in a RuntimeIOException naming the file location; the stream is closed before throwing.","triggerScenarios":"Calling getMetadata() or iterating (fileReader) when the InputFile stream() throws, the seekable stream cannot be created, or DataFileReader construction fails due to an invalid Avro magic header or unsupported codec.","commonSituations":"S3/GCS credentials missing or expired (403/404 surfaces as IOException); HDFS NameNode unavailable; file corrupted in transit; reading a file whose compression codec (e.g. zstd) library is absent.","solutions":["Verify storage credentials and endpoint configuration for the configured FileIO","Check the object exists and its size is > 0 (truncated/empty upload)","Add the missing codec dependency (e.g. aircompressor/zstd-jni) if the Avro codec is unsupported","Retry with a fresh InputFile to rule out transient network errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"Preconditions.checkNotNull(inputFile, \"InputFile required\");\nif (inputFile.getLength() == 0) throw new IllegalStateException(\"Empty file: \" + inputFile.location());","typeGuard":null,"tryCatchPattern":"try (CloseableIterable<D> it = Avro.read(in).project(schema).build()) {\n  it.forEach(consumer);\n} catch (RuntimeIOException e) {\n  throw new RuntimeException(\"Open failed for \" + in.location(), e);\n}","preventionTips":["Verify cloud credentials/IAM permissions for the bucket/container","Add codec dependencies matching the writer's codec","Stat the object before opening to catch deletion/truncation early","Keep FileIO configuration (endpoints, regions) consistent across jobs"],"tags":["avro","io","file-open"],"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-14T16:17:12.679Z"}