question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

generate_presigned_url not working with complete_multipart_upload

See original GitHub issue

Hello, I am trying to generate a presigned URL for complete_multipart_upload, but I’m getting this error when running my code:

Traceback (most recent call last):
  File "/dev-env/test/chalicelib/rmodel.py", line 280, in __call__
    return funct(*args, **kwargs)
  File "/dev-env/test/chalicelib/upload.py", line 201, in create_complete_upload
    'MultipartUpload': upload})
  File "/dev-env/venv/lib/python3.7/site-packages/botocore/signers.py", line 595, in generate_presigned_url
    operation_name=operation_name)
  File "/dev-env/venv/lib/python3.7/site-packages/botocore/signers.py", line 268, in generate_presigned_url
    'presign-url', expires_in, signing_name)
  File "/dev-env/venv/lib/python3.7/site-packages/botocore/signers.py", line 157, in sign
    auth.add_auth(request)
  File "/dev-env/venv/lib/python3.7/site-packages/botocore/auth.py", line 362, in add_auth
    self._modify_request_before_signing(request)
  File "/dev-env/venv/lib/python3.7/site-packages/botocore/auth.py", line 525, in _modify_request_before_signing
    query_dict.update(self._get_body_as_dict(request))
  File "/dev-env/venv/lib/python3.7/site-packages/botocore/auth.py", line 550, in _get_body_as_dict
    data = json.loads(data.decode('utf-8'))
  File "/dev-env/Packages/miniconda3/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/dev-env/Packages/miniconda3/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/dev-env/Packages/miniconda3/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This is the code:

s3_client = boto3.client('s3')
signed_url = s3_client.generate_presigned_url('complete_multipart_upload',
    ExpiresIn=3600,
    HttpMethod='POST',
    Params={
        'Bucket': _BUCKET,
        'Key': key,
        'UploadId': upload_id,
        'MultipartUpload': upload})

If I call s3_client.complete_multipart_upload with the same arguments specified in Params, then the operation completes without issues. From the error it looks like AWS is returning an unexpected response message to boto.

The boto3 version is 1.10.2

Thank you,

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kdailycommented, Apr 21, 2021

Hi @Caian, I can reproduce this issue. Thanks for your debugging thus far. Marking as a bug and will investigate further.

0reactions
alonblcommented, Aug 11, 2022

Reproduction does not need any credentials or actual objects, but simple invocation.

import boto3
from botocore.client import Config

s3 = boto3.client(
    's3',
    region_name="us-east-1",
    config=Config(signature_version="s3v4"),
)

signed_url = s3.generate_presigned_url(
    ClientMethod ='complete_multipart_upload',
    Params = {
       'Bucket': "bucket1",
       'UploadId': "id1",
       'Key': "key1",
       'UploadId': "id1",
       'MultipartUpload': {'Parts': []},
    }
)
Traceback (most recent call last):
  File "/home/alonbl/exodigo/alonbl-misc/aws-example/a.py", line 10, in <module>
    signed_url = s3.generate_presigned_url(
  File "/home/alonbl/exodigo/alonbl-misc/aws-example/x1/lib/python3.10/site-packages/botocore/signers.py", line 661, in generate_presigned_url
    return request_signer.generate_presigned_url(
  File "/home/alonbl/exodigo/alonbl-misc/aws-example/x1/lib/python3.10/site-packages/botocore/signers.py", line 312, in generate_presigned_url
    self.sign(
  File "/home/alonbl/exodigo/alonbl-misc/aws-example/x1/lib/python3.10/site-packages/botocore/signers.py", line 187, in sign
    auth.add_auth(request)
  File "/home/alonbl/exodigo/alonbl-misc/aws-example/x1/lib/python3.10/site-packages/botocore/auth.py", line 412, in add_auth
    self._modify_request_before_signing(request)
  File "/home/alonbl/exodigo/alonbl-misc/aws-example/x1/lib/python3.10/site-packages/botocore/auth.py", line 576, in _modify_request_before_signing
    query_dict.update(_get_body_as_dict(request))
  File "/home/alonbl/exodigo/alonbl-misc/aws-example/x1/lib/python3.10/site-packages/botocore/auth.py", line 96, in _get_body_as_dict
    data = json.loads(data.decode('utf-8'))
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Multipart uploads with S3 pre-signed URLs · Issue #1548
Is your feature request related to a problem? ... But i can not find it on asw-sdk-cpp just like http... ... step-2:GeneratePresignedUrl
Read more >
S3 Java- Multipart upload using a presigned URL?
For a single PUT (or GET) operation, one can use generatePresignedUrl , but I wouldn't know how to apply this to multipart upload...
Read more >
AmazonS3 (AWS SDK for Java - 1.12.368)
Provides an interface for accessing the Amazon S3 web service. Note: Do not directly implement this interface, new methods are added to it...
Read more >
AmazonS3.generatePresignedUrl - Java
public URL getPreSignedUrl(long attachmentId, HttpMethod method, boolean unaccelerated) { AmazonS3 client = new AmazonS3Client(credentials); ...
Read more >
aws/aws-sdk-go
Content should always be returned in CSV format, but I'm not 100% sure; GetCredentialReport. ... You need to do a little extra work...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found