From 7d8a795e959d92e03d1789a95b1ebf7c12d800ad Mon Sep 17 00:00:00 2001 From: jonaustin09 Date: Fri, 4 Aug 2023 20:27:47 +0400 Subject: [PATCH] fix: Fixes #184, Change InvalidArgument to InvalidRange error for GetObject by range for larger ragnes --- backend/posix/posix.go | 2 +- integration/tests.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/posix/posix.go b/backend/posix/posix.go index f4264f15..79abec9a 100644 --- a/backend/posix/posix.go +++ b/backend/posix/posix.go @@ -1095,7 +1095,7 @@ func (p *Posix) GetObject(_ context.Context, input *s3.GetObjectInput, writer io } if startOffset+length > fi.Size()+1 { - return nil, s3err.GetAPIError(s3err.ErrInvalidRequest) + return nil, s3err.GetAPIError(s3err.ErrInvalidRange) } if acceptRange != "" { diff --git a/integration/tests.go b/integration/tests.go index d5b56bc2..7f390bcb 100644 --- a/integration/tests.go +++ b/integration/tests.go @@ -1087,6 +1087,19 @@ func TestRangeGet(s *S3Conf) { return } + lgRange := "bytes=20000000-30000000000" + ctx, cancel = context.WithTimeout(context.Background(), shortTimeout) + _, err = s3client.GetObject(ctx, &s3.GetObjectInput{ + Bucket: &bucket, + Key: &name, + Range: &lgRange, + }) + cancel() + if err == nil { + failF("%v: expected range error", testname) + return + } + // Invalid range invRange := "bytes=100-asd" ctx, cancel = context.WithTimeout(context.Background(), shortTimeout)