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

missing ContentLength in s3.Object.get() response when requesting partial content #2964

Closed
gerazenobi opened this issue May 6, 2020 · 4 comments · Fixed by #3421
Closed

Comments

@gerazenobi
Copy link

gerazenobi commented May 6, 2020

Steps to reproduce:

from moto import mock_s3
import boto3

file_path = "..."
with mock_s3():
    bucket = "test"
    object_key = "key"
    s3 = boto3.resource("s3")
    s3.create_bucket(Bucket=bucket)
    with open(file_path, "rb") as file:
        s3.Object(bucket, object_key).put(Body=file)

    file = s3.Object(bucket, object_key)
    response = file.get(Range="bytes=0-1024")
    print(response["ContentLength"])

Expected behavior:

1025

Actual behavior:

KeyError: 'ContentLength'

Additional information:
This only happens when requesting partial content. Possibly other important response's headers are ignored as well since the headers argument is not being used within _handle_range_header, as seen here.

Versions

  • moto 1.3.14
  • boto 2.49.0
  • boto3 1.13.3
  • botocore 1.16.3
@RonRothman
Copy link
Contributor

Greetings,

We're hitting this too, and it's breaking our tests. I see this has been open since May, and is labelled an "Enhancement." Is that just an oversight? Can we bump this up to "Bug?"

@bblommers
Copy link
Collaborator

Hi @RonRothman, my definition of a bug (in Moto's context) is anything that behaves differently from boto3.
In this case, the entire implementation is missing - and therefore the enhancement-label is more suitable IMO.

@RonRothman
Copy link
Contributor

Thanks @bblommers, that makes sense. And I see that a fix is on the way--thanks for that as well!

@bblommers
Copy link
Collaborator

No problem @RonRothman!

This is now partof moto >= 1.3.16.dev79

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

Successfully merging a pull request may close this issue.

3 participants