{"record":{"id":"85dfac814cac4345","repo":"prestodb/presto","slug":"attempted-to-seek-or-read-past-the-end-of-the-file","errorCode":null,"errorMessage":"Attempted to seek or read past the end of the file","messagePattern":"Attempted to seek or read past the end of the file","errorType":"exception","errorClass":"EOFException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java","lineNumber":1013,"sourceCode":"            try {\n                return retry()\n                        .maxAttempts(maxAttempts)\n                        .exponentialBackoff(BACKOFF_MIN_SLEEP, maxBackoffTime, maxRetryTime, 2.0)\n                        .stopOn(InterruptedException.class, UnrecoverableS3OperationException.class, EOFException.class, FileNotFoundException.class, AbortedException.class)\n                        .onRetry(STATS::newGetObjectRetry)\n                        .run(\"getS3Object\", () -> {\n                            InputStream stream;\n                            try {\n                                GetObjectRequest request = new GetObjectRequest(host, keyFromPath(path))\n                                        .withRange(position, (position + length) - 1);\n                                stream = s3.getObject(request).getObjectContent();\n                            }\n                            catch (RuntimeException e) {\n                                STATS.newGetObjectError();\n                                if (e instanceof AmazonS3Exception) {\n                                    switch (((AmazonS3Exception) e).getStatusCode()) {\n                                        case HTTP_RANGE_NOT_SATISFIABLE:\n                                            throw new EOFException(CANNOT_SEEK_PAST_EOF);\n                                        case HTTP_NOT_FOUND:\n                                            throw new FileNotFoundException(\"File does not exist: \" + path);\n                                        case HTTP_FORBIDDEN:\n                                        case HTTP_BAD_REQUEST:\n                                            throw new UnrecoverableS3OperationException(path, e);\n                                    }\n                                }\n                                throw e;\n                            }\n\n                            STATS.connectionOpened();\n                            try {\n                                int read = 0;\n                                while (read < length) {\n                                    int n = stream.read(buffer, offset + read, length - read);\n                                    if (n <= 0) {\n                                        if (read > 0) {\n                                            return read;","sourceCodeStart":995,"sourceCodeEnd":1031,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java#L995-L1031","documentation":"PrestoS3InputStream read path: after retries, a read/seek reached beyond the object's content length (EOF confirmed by the retry policy's stopOn EOFException), so the client attempted to read past the end of the S3 object.","triggerScenarios":"Thrown at presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java:1013 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the reader's position arithmetic against the file length","Handle truncated objects by re-listing the directory or refreshing file status"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}