{"record":{"id":"e978af39112858fb","repo":"apache/iceberg","slug":"failed-to-fetch-file-s","errorCode":null,"errorMessage":"Failed to fetch file: %s","messagePattern":"Failed to fetch file: (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/io/EagerInputFile.java","lineNumber":88,"sourceCode":"    return delegate.exists();\n  }\n\n  @Override\n  public SeekableInputStream newStream() {\n    byte[] bytes = new byte[(int) length];\n    try (SeekableInputStream src = delegate.newStream()) {\n      IOUtil.readFully(src, bytes, 0, bytes.length);\n      // reads from the already open stream; no additional request\n      if (src.read() != -1) {\n        throw new IOException(\n            \"Incorrect length provided for file \"\n                + delegate.location()\n                + \", given a length of \"\n                + length\n                + \" and did not reach the end of stream\");\n      }\n    } catch (IOException e) {\n      throw new RuntimeIOException(e, \"Failed to fetch file: %s\", delegate.location());\n    }\n    return new EagerInputStream(bytes);\n  }\n\n  /** An {@link EagerInputFile} that preserves the delegate's Hadoop configuration. */\n  private static class EagerInputFileConfigurable extends EagerInputFile\n      implements HadoopConfigurable {\n\n    private final HadoopConfigurable delegate;\n\n    EagerInputFileConfigurable(InputFile delegate, long length) {\n      super(delegate, length);\n      Preconditions.checkArgument(\n          delegate instanceof HadoopConfigurable,\n          \"Cannot create Hadoop Configurable Eager Input File because %s does not implement HadoopConfigurable\",\n          delegate.getClass().getName());\n      this.delegate = (HadoopConfigurable) delegate;\n    }","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/io/EagerInputFile.java#L70-L106","documentation":"EagerInputFile.newStream wraps any IOException from fully reading the file into a RuntimeIOException with message 'Failed to fetch file: <location>'. It means the eager whole-file read into memory failed (missing file, permission problem, or mid-read IO error).","triggerScenarios":"Calling newStream() on an EagerInputFile when the delegate stream cannot be opened or read fully (file absent, access denied, storage error) — including the incorrect-length IOException from the EOF check.","commonSituations":"Reading an object that was deleted/expired; wrong credentials or region for the bucket; network failure during bulk read; length mismatch from a stale length parameter.","solutions":["Check the wrapped cause; if 'Incorrect length provided...', fix the supplied length.","Verify the file exists and is readable in storage.","Retry; transient storage errors are common for eager full-file reads.","If files are large, avoid eager loading and use a streaming InputFile to reduce failure surface and memory pressure."],"exampleFix":"// before\nInputFile eager = ContentCache.buildEagerInputFile(location, delegate); // may RuntimeIOException\n// after\ntry {\n  return eager.newStream();\n} catch (RuntimeIOException e) {\n  LOG.warn(\"Eager fetch failed for {}\", location, e);\n  return delegate.newStream(); // fall back to lazy streaming\n}","handlingStrategy":"fallback","validationCode":"if (!io.newInputFile(location).exists()) {\n  throw new NotFoundException(\"File missing: \" + location);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return eagerFile.newStream();\n} catch (RuntimeIOException e) {\n  LOG.warn(\"Eager fetch of {} failed, using streaming\", location, e);\n  return delegate.newStream();\n}","preventionTips":["Only use eager input files for small files (footer-sized)","Check credentials/region config when fetches fail systematically","Retry transient network failures before giving up","Prefer streaming reads for large files to limit memory and failure surface"],"tags":["io","file-read","runtime-exception"],"backgroundTag":"file-read-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"}