MissingContentLength error when uploading object to Tigris

An app that is previously been working without issue is now getting the following error when uploading an object to Tigris:

botocore.exceptions.ClientError: An error occurred (MissingContentLength) when calling the PutObject operation: You must provide the Content-Length HTTP header.

I have reproduced the error using this very simple example, which is taken from the Tigris docs:

import boto3

# Create S3 service client
svc = boto3.client(
    "s3",
    endpoint_url=AWS_ENDPOINT_URL_S3,
    aws_access_key_id=AWS_ACCESS_KEY_ID,
    aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
)

svc.upload_file("bar.txt", BUCKET_NAME, "bar.txt")

The file bar.txt simply contains the text foo.

What is going on?

Same error when using the following awscli command (I assume because it also uses the boto3 backend):

aws s3 cp bar.txt s3://test-bucket/bar.txt

I could not reproduce it in either way. Can you post the debug output with aws cli by supplying --debug

Here is the output: https://pastebin.com/raw/eVEE9ipf

I just realised my version of boto3 was not pinned. Downgrading from boto3 1.36.0 to 1.35.99 fixes the issue for me.

Same issue here! I am using aws-cli, all was uploading fine until today I noticed this error:

upload failed: checkout/tracker.js to s3://bucket-xxx/checkout/1.1.5/tracker.js  
An error occurred (MissingContentLength) when calling the PutObject operation: 
You must provide the Content-Length HTTP header

Found the reason! Tigris support responded. Turns out the issue is in the latest version of awscli with the botocore package. I tried downgrading the aws-cli version and it works fine.

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.22.18.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.