Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect response code when Downloading S3 object with invalid range #2587

Closed
charleswhchan opened this issue Jun 19, 2020 · 6 comments
Closed
Assignees

Comments

@charleswhchan
Copy link

Type of request: This is a ...

[x] bug report
[ ] feature request

Detailed description

When download invalid a range of bytes from S3 with an invalid range. localstack returns an incorrect error code RequestedRangeNotSatisfiable instead of InvalidRange

Expected behavior

(from S3) Err: InvalidRange: The requested range is not satisfiable

Actual behavior

(from localstack) RequestedRangeNotSatisfiable

Client code (AWS SDK code snippet, or sequence of "awslocal" commands)

	// Test S3 error code when invalid byte range is specified
	// Note: the file should be smaller than the range specified
	contentLength := 1000000
	rangeByteHeader := "bytes=1000-1000000"
        fmt.Printf("    range:  %v\n", rangeByteHeader)

	getObjectInput := &s3.GetObjectInput{
		Bucket: aws.String(bucket),
		Key:    aws.String(key),
		Range:  aws.String(rangeByteHeader),
	}
	buffer := aws.NewWriteAtBuffer(make([]byte, contentLength))

	fmt.Println("downloader.Download ...")
	size, err := downloader.Download(buffer, getObjectInput)
	_ = size
	fmt.Printf("Err: %+v\n", err)
@whummer
Copy link
Member

whummer commented Jun 21, 2020

Thanks for reporting @charleswhchan . This should be fixed in #2598 - can you please give it a try with the latest version of the Docker image? Please report here if the problem persists. Thanks

@whummer whummer closed this as completed Jun 21, 2020
@charleswhchan
Copy link
Author

charleswhchan commented Jun 21, 2020

Hi @whummer, I tried the latest docker image and I am still seeing the error:
"error":"RequestedRangeNotSatisfiable: Requested Range Not Satisfiable\n\tstatus code: 416

Looking at the test case and comparing to my sample code (above). I am using Download().

Perhaps the fix needs to be applied some where else as well? Maybe a test using download_file() or download_fileobj() will help expose the problem?

@whummer whummer reopened this Jun 22, 2020
@whummer
Copy link
Member

whummer commented Jun 22, 2020

Hi @charleswhchan , sorry, perhaps my response came a few minutes too early. Please note that it can take some time for our CI system to build and push the latest image. Can you please give it another try after pulling latest, and double-check whether the problem still persists? Thanks!

@charleswhchan
Copy link
Author

Thanks @whummer for the quick turnaround. You are right, it is working with the following image:

$ docker pull localstack/localstack:latest
latest: Pulling from localstack/localstack
8a4e9a21a873: Pull complete 
Digest: sha256:3db28dbf80b9587376d11306398e1d2e8ee32bfbb5bf7528d4dd84a0f314cdc5
Status: Downloaded newer image for localstack/localstack:latest
docker.io/localstack/localstack:latest

Please close the ticket. 👍

@tejas03
Copy link

tejas03 commented Jan 27, 2023

Thanks @whummer for the quick turnaround. You are right, it is working with the following image:

$ docker pull localstack/localstack:latest
latest: Pulling from localstack/localstack
8a4e9a21a873: Pull complete 
Digest: sha256:3db28dbf80b9587376d11306398e1d2e8ee32bfbb5bf7528d4dd84a0f314cdc5
Status: Downloaded newer image for localstack/localstack:latest
docker.io/localstack/localstack:latest

Please close the ticket. 👍

@tejas03
Copy link

tejas03 commented Jan 27, 2023

This is issue still happening for larger files as of 1/27/23. I am using boto3==1.21.35

[2023-01-10, 17:25:29 EST] "message": "multiprocessing.pool.RemoteTraceback: \n"""\nTraceback (most recent call last):\n File "/usr/lib64/python3.7/multiprocessing/pool.py", line 121, in worker\n result = (True, func(*args, **kwds))\n File "/usr/lib64/python3.7/multiprocessing/pool.py", line 47, in starmapstar\n return list(itertools.starmap(args[0], args[1]))\n File "fpcp_file_manager.py", line 655, in func_download_s3_files\n s3.download_file(awsbucket, key, dest_filename)\n File "/usr/local/lib/python3.7/site-packages/boto3/s3/inject.py", line 195, in download_file\n callback=Callback,\n File "/usr/local/lib/python3.7/site-packages/boto3/s3/transfer.py", line 320, in download_file\n future.result()\n File "/usr/local/lib/python3.7/site-packages/s3transfer/futures.py", line 103, in result\n return self._coordinator.result()\n File "/usr/local/lib/python3.7/site-packages/s3transfer/futures.py", line 266, in result\n raise self._exception\n File "/usr/local/lib/python3.7/site-packages/s3transfer/tasks.py", line 139, in call\n return self._execute_main(kwargs)\n File "/usr/local/lib/python3.7/site-packages/s3transfer/tasks.py", line 162, in _execute_main\n return_value = self._main(kwargs)\n File "/usr/local/lib/python3.7/site-packages/s3transfer/download.py", line 570, in _main\n Bucket=bucket, Key=key, extra_args\n File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 415, in _api_call\n return self._make_api_call(operation_name, kwargs)\n File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 745, in _make_api_call\n raise error_class(parsed_response, operation_name)\nbotocore.exceptions.ClientError: An error occurred (InvalidRange) when calling the GetObject operation: The requested range is not satisfiable\n"""\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "fpcp_file_manager.py", line 1287, in \n main()\n File "fpcp_file_manager.py", line 1238, in main\n if download_s3_files == True: exec_download_s3_files()\n File "fpcp_file_manager.py", line 1088, in exec_download_s3_files\n pool.starmap(func_download_s3_files, zip(keys, repeat(download_destpath)), chunksize=10)\n File "/usr/lib64/python3.7/multiprocessing/pool.py", line 276, in starmap\n return self._map_async(func, iterable, starmapstar, chunksize).get()\n File "/usr/lib64/python3.7/multiprocessing/pool.py", line 657, in get\n raise self._value\nbotocore.exceptions.ClientError: An error occurred (InvalidRange) when calling the GetObject operation: The requested range is not satisfiable\n",

Another issue is while deleting the larger file. However for delete-file it is not throwing any error. It simply skip the file from deleting as below. First and last one were deleted. middle one was not deleted which is causing duplication issue in processing.

{'DeleteMarker': True,
'ResponseMetadata': {'HTTPHeaders': {'date': 'Tue, 17 Jan 2023 02:24:42 GMT',
'server': 'AmazonS3',
'x-amz-delete-marker': 'true',
'x-amz-id-2': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'x-amz-request-id': 'ABCDEFG0123456',
'x-amz-version-id': 'zzzzzzzzzzzzzzzzzzzzzzzz'},
'HTTPStatusCode': 204,
'HostId': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'RequestId': 'ABCDEFG0123456',
'RetryAttempts': 0},
'VersionId': 'zzzzzzzzzzzzzzzzzzzzzzzz'}
files to delete - abcxyz/test1.dat.gz
{'DeleteMarker': True,
'ResponseMetadata': {'HTTPHeaders': {'date': 'Tue, 17 Jan 2023 02:24:42 GMT',
'server': 'AmazonS3',
'x-amz-delete-marker': 'true',
'x-amz-id-2': 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy',
'x-amz-request-id': '0987654ABCDE',
'x-amz-version-id': 'xxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyy'files to delete - abcxyz/test2.dat.gz
{'DeleteMarker': True,
'ResponseMetadata': {'HTTPHeaders': {'date': 'Tue, 17 Jan 2023 02:24:42 GMT',
'server': 'AmazonS3',
'x-amz-delete-marker': 'true',
'x-amz-id-2': 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',
'x-amz-request-id': 'ABC123XYZ789',
'x-amz-version-id': 'yyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzz'},
'HTTPStatusCode': 204,
'HostId': 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',
'RequestId': 'ABC123XYZ789',
'RetryAttempts': 0},
'VersionId': 'yyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzz'}
files to delete - abcxyz/test3.dat.gz

Can you please reopen this ticket and provide an assistance? Please let me know if you need further information. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants