{"record":{"id":"9fdc85a7d4f29edf","repo":"apache/iceberg","slug":"location-does-not-exist-s","errorCode":null,"errorMessage":"Location does not exist: %s","messagePattern":"Location does not exist: (.+?)","errorType":"exception","errorClass":"NotFoundException","httpStatus":null,"severity":"error","filePath":"aws/src/main/java/org/apache/iceberg/aws/s3/S3InputStream.java","lineNumber":263,"sourceCode":"  private void openStream() throws IOException {\n    openStream(false);\n  }\n\n  private void openStream(boolean closeQuietly) throws IOException {\n    GetObjectRequest.Builder requestBuilder =\n        GetObjectRequest.builder()\n            .bucket(location.bucket())\n            .key(location.key())\n            .range(String.format(\"bytes=%s-\", pos));\n\n    S3RequestUtil.configureEncryption(s3FileIOProperties, requestBuilder);\n\n    closeStream(closeQuietly);\n\n    try {\n      stream = s3.getObject(requestBuilder.build(), ResponseTransformer.toInputStream());\n    } catch (NoSuchKeyException e) {\n      throw new NotFoundException(e, \"Location does not exist: %s\", location);\n    }\n  }\n\n  @VisibleForTesting\n  void resetForRetry() throws IOException {\n    openStream(true);\n  }\n\n  private void closeStream(boolean closeQuietly) throws IOException {\n    if (stream != null) {\n      // if we aren't at the end of the stream, and the stream is abortable, then\n      // call abort() so we don't read the remaining data with the Apache HTTP client\n      abortStream();\n      try {\n        stream.close();\n      } catch (IOException e) {\n        if (closeQuietly) {\n          stream = null;","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/s3/S3InputStream.java#L245-L281","documentation":"S3InputStream throws a NotFoundException when S3 responds with NoSuchKeyException while opening the object input stream. It means the S3 key backing the given Iceberg location no longer exists, so the stream cannot be opened (or re-opened after a retry).","triggerScenarios":"Calling openStream (directly or via resetForRetry after a transient failure) when the underlying S3 object was deleted or never written; s3.getObject returns NoSuchKeyException.","commonSituations":"Another process expired/deleted the file (e.g. orphan cleanup, expireSnapshots) while it was being read; typos in the location URI; reading data files from a table whose metadata was rolled back; eventual consistency races in custom catalogs.","solutions":["Verify the S3 key exists with s3FileIO (io.newInputFile(location).exists()) before reading.","Check whether the file was deleted concurrently by cleanup jobs (expireSnapshots, removeOrphanFiles) and adjust retention.","Re-read from a fresh, current table snapshot instead of a stale cached file reference.","Check for typos or stale catalog entries producing a wrong location URI."],"exampleFix":"// before\nInputFile in = io.newInputFile(\"s3://bucket/stale/data.parquet\");\nin.newStream(); // NotFoundException\n// after\nInputFile in = io.newInputFile(\"s3://bucket/stale/data.parquet\");\nif (!in.exists()) {\n  throw new IllegalStateException(\"File missing; refresh table snapshot\");\n}\nin.newStream();","handlingStrategy":"validation","validationCode":"// Java\nInputFile in = io.newInputFile(location);\nif (!in.exists()) {\n  throw new IllegalStateException(\"Object missing at \" + location + \"; refresh snapshot or restore cleanup retention\");\n}","typeGuard":null,"tryCatchPattern":"// Java\ntry {\n  in.newStream();\n} catch (NotFoundException e) {\n  LOG.warn(\"Object vanished: {}\", location);\n  // re-plan read from current table snapshot or surface a user-facing error\n}","preventionTips":["Check file existence before long-running reads of external references","Keep expireSnapshots/removeOrphanFiles retention longer than maximum job duration","Re-resolve file locations from the latest table snapshot instead of caching them"],"tags":["s3","io","not-found","fileio"],"backgroundTag":"resource-not-found","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"}