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

Submitting a S3 CopyObject to replace user metadata with Content-Length 0 causes Error 500 after the checksum workaround #8592

Closed
jeking3 opened this issue Feb 13, 2025 · 1 comment · Fixed by #8596
Labels

Comments

@jeking3
Copy link
Contributor

jeking3 commented Feb 13, 2025

Example request:

[DEBUG] 2025-02-13 20:48:40.015 CURL [140340847924992] (HeaderOut) PUT /s3testbucket/dst/testfile HTTP/1.1
Host: 127.0.0.1:12509
Accept: */*
amz-sdk-invocation-id: 008050B0-3919-4A52-AA41-5E93710D4049
amz-sdk-request: ttl=20250213T205140Z; attempt=4
authorization: ...
content-encoding: aws-chunked
content-length: 0
content-type: binary/octet-stream
user-agent: aws-sdk-cpp/1.11.500 md/internal ua/2.1 api/S3 os/Linux#5.10.233-204.894.x86_64 lang/c++#C++11 md/aws-crt#0.30.1 md/arch#x86_64 md/GCC#7.3.1 m/Z,b
x-amz-api-version: 2006-03-01
x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-amz-copy-source: s3testbucket/dst/testfile
x-amz-copy-source-if-match: "620f0b67a91f7f74151bc5be745b7110"
x-amz-date: 20250213T204840Z
x-amz-meta-last-modified: 1739479675000
x-amz-meta-usermetakey: usermetaval
x-amz-metadata-directive: REPLACE
x-amz-security-token: ...

Example 500 stack:

Error on request:
Traceback (most recent call last):
  File "/test-runtime/lib/python3.9/site-packages/werkzeug/serving.py", line 370, in run_wsgi
    execute(self.server.app)
  File "/test-runtime/lib/python3.9/site-packages/werkzeug/serving.py", line 331, in execute
    application_iter = app(environ, start_response)
  File "/test-runtime/lib/python3.9/site-packages/moto/moto_server/werkzeug_app.py", line 264, in __call__
    return backend_app(environ, start_response)
  File "/test-runtime/lib/python3.9/site-packages/flask/app.py", line 1478, in __call__
    return self.wsgi_app(environ, start_response)
  File "/test-runtime/lib/python3.9/site-packages/flask/app.py", line 1458, in wsgi_app
    response = self.handle_exception(e)
  File "/test-runtime/lib/python3.9/site-packages/flask_cors/extension.py", line 176, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/test-runtime/lib/python3.9/site-packages/flask/app.py", line 1455, in wsgi_app
    response = self.full_dispatch_request()
  File "/test-runtime/lib/python3.9/site-packages/flask/app.py", line 869, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/test-runtime/lib/python3.9/site-packages/flask_cors/extension.py", line 176, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/test-runtime/lib/python3.9/site-packages/flask/app.py", line 867, in full_dispatch_request
    rv = self.dispatch_request()
  File "/test-runtime/lib/python3.9/site-packages/flask/app.py", line 852, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/test-runtime/lib/python3.9/site-packages/moto/core/utils.py", line 112, in __call__
    result = self.callback(request, request.url, dict(request.headers))
  File "/test-runtime/lib/python3.9/site-packages/moto/core/responses.py", line 307, in _inner
    response = getattr(cls(), to_call.__name__)(request, full_url, headers)
  File "/test-runtime/lib/python3.9/site-packages/moto/s3/responses.py", line 1377, in key_response
    self.setup_class(request, full_url, headers)
  File "/test-runtime/lib/python3.9/site-packages/moto/s3/responses.py", line 191, in setup_class
    self.body = request.input_stream.getvalue()
AttributeError: '_io.BufferedReader' object has no attribute 'getvalue'

Code in question:

self.body = request.input_stream.getvalue()

I'm not sure where the BufferedReader comes from; it does not appear to be from moto.

@bpandola
Copy link
Collaborator

I put a comment in #8596 with some thoughts on this. Something that would also be helpful, if you're up for it, would be to stand up a minimal failing test case using the AWS SDK for C++. You can look in the other_langs directory in moto for some examples using other AWS SDKs.

jeking3 added a commit to jeking3/moto that referenced this issue Feb 17, 2025
jeking3 added a commit to jeking3/moto that referenced this issue Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants