Skip to content

Seeking to offset=length results in The requested range 'bytes=N--1' is not satisfiable error #2166

@WGH-

Description

@WGH-

If you seek to an offset exactly equal to length, subsequent read will return rather unexpected "Requested Range Not Satisfiable" error instead of either io.EOF or empty data.

I think these strict inequalities should be replaced with greater-or-equal to fix this bug:

minio-go/api-get-object.go

Lines 567 to 576 in f4c4350

case 0:
if o.objectInfo.Size > -1 && offset > o.objectInfo.Size {
return 0, io.EOF
}
newOffset = offset
case 1:
if o.objectInfo.Size > -1 && o.currOffset+offset > o.objectInfo.Size {
return 0, io.EOF
}
newOffset += offset

Somewhat related to #2155: changing the library to allow past-the-end seeks will fix this as well.

HEAD /XXX/logs/1 HTTP/1.1
Host: 127.0.0.1:9000
User-Agent: MinIO (linux; amd64) minio-go/v7.0.74
Authorization: AWS4-HMAC-SHA256 Credential=XXX/20251009/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=ac2c05657ab592d24c7d43d3de32fd7cfd716746bf2dcce364aa53cd4ac11a3f
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
X-Amz-Date: 20251009T231603Z


HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 6306
Content-Type: text/plain
ETag: "2d9df643507c5e8a783a4a57818e305f"
Last-Modified: Thu, 09 Oct 2025 17:39:48 GMT
Server: MinIO
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Origin
Vary: Accept-Encoding
X-Amz-Id-2: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8
X-Amz-Request-Id: 186CF5C11188BB95
X-Content-Type-Options: nosniff
X-Ratelimit-Limit: 5592
X-Ratelimit-Remaining: 5592
X-Xss-Protection: 1; mode=block
Date: Thu, 09 Oct 2025 23:16:03 GMT


GET /XXX/logs/1 HTTP/1.1
Host: 127.0.0.1:9000
User-Agent: MinIO (linux; amd64) minio-go/v7.0.74
Authorization: AWS4-HMAC-SHA256 Credential=XXX/20251009/us-east-1/s3/aws4_request, SignedHeaders=host;if-match;range;x-amz-content-sha256;x-amz-date, Signature=ae7d08cfd2339e23fed2d5e8b25dd34bc38c02b776d70e6add61462c3332e02a
If-Match: "2d9df643507c5e8a783a4a57818e305f"
Range: bytes=6306-
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
X-Amz-Date: 20251009T231603Z


HTTP/1.1 416 Requested Range Not Satisfiable
Accept-Ranges: bytes
Content-Length: 448
Content-Type: application/xml
Server: MinIO
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Origin
Vary: Accept-Encoding
X-Amz-Id-2: dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8
X-Amz-Request-Id: 186CF5C1119FAF1C
X-Content-Type-Options: nosniff
X-Ratelimit-Limit: 5592
X-Ratelimit-Remaining: 5592
X-Xss-Protection: 1; mode=block
Date: Thu, 09 Oct 2025 23:16:03 GMT

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidRange</Code><Message>The requested range &#39;bytes=6306--1&#39; is not satisfiable</Message><Key>logs/1</Key><BucketName>XXX</BucketName><Resource>/XXX/logs/1</Resource><RequestId>186CF5C1119FAF1C</RequestId><HostId>dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8</HostId><ActualObjectSize>6306</ActualObjectSize><RangeRequested>6306--1</RangeRequested></Error>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions