apache/flink · error · IOException

Failed to open S3 stream for {}/{}

Error message

Failed to open S3 stream for {}/{}

What it means

Error "Failed to open S3 stream for {}/{}" thrown in apache/flink.

Source

Thrown at flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/NativeS3InputStream.java:190

            try {
                GetObjectRequest.Builder requestBuilder =
                        GetObjectRequest.builder().bucket(bucketName).key(key);

                if (streamPos > 0) {
                    requestBuilder.range(String.format("bytes=%d-", streamPos));
                    LOG.debug(
                            "Opening S3 stream with range: bytes={}-{}",
                            streamPos,
                            contentLength - 1);
                } else {
                    LOG.debug("Opening S3 stream for full object: {} bytes", contentLength);
                }
                currentStream = s3Client.getObject(requestBuilder.build());
                bufferedStream = new BufferedInputStream(currentStream, readBufferSize);
            } catch (Exception e) {
                releaseStreams();
                throw new IOException("Failed to open S3 stream for " + bucketName + "/" + key, e);
            }
        } finally {
            lock.unlock();
        }
    }

    /** Aborts the in-flight HTTP connection to avoid draining remaining bytes on close. */
    @GuardedBy("lock")
    private void abortCurrentStream() {
        assert lock.isHeldByCurrentThread() : "abortCurrentStream() requires lock to be held";
        if (currentStream != null) {
            try {
                currentStream.abort();
            } catch (RuntimeException e) {
                LOG.warn("Error aborting S3 response stream for {}/{}", bucketName, key, e);
            }
        }
    }

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Address the cause reported by the error message: Failed to open S3 stream for the reported value/the reported value
  2. Verify the inputs, configuration values, and classpath/dependency setup related to this operation, then retry.

Example fix

Correct the condition described ("Failed to open S3 stream for the reported value/the reported value") and rerun the job or command.

When it happens

Trigger: Triggered at runtime when the operation fails because: Failed to open S3 stream for the reported value/the reported value.

Common situations: Commonly caused by misconfiguration, missing dependencies or files, unsupported types or operations, or invalid user input leading to: Failed to open S3 stream for the reported value/the reported value.


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/fa40ecbabc814ff2. Report an issue: GitHub.