Skip to content

Enabling versioning through CLI fails (but works through curl) #2635

@mark-langer

Description

@mark-langer

Goal
Enable versioning for a bucket through the AWS CLI.

Summary

  • Enabling versioning through AWS CLI doesn't work ❌
  • Enabling versioning through curl works ✅

Code to create bucket with versioning and test versioning

# Create bucket
aws --endpoint-url=http://localhost:9090 s3api create-bucket --bucket test-versioning-bucket

# Enable versioning immediately
aws --endpoint-url=http://localhost:9090 s3api put-bucket-versioning --bucket test-versioning-bucket --versioning-configuration Status=Enabled

# Verify versioning is now enabled
aws --endpoint-url=http://localhost:9090 s3api get-bucket-versioning --bucket test-versioning-bucket --output json

# Add some objects first
echo "content1" > test1.txt
aws --endpoint-url=http://localhost:9090 s3api put-object --bucket test-versioning-bucket --key test1.txt --body test1.txt

# Delete to create delete marker
aws --endpoint-url=http://localhost:9090 s3api delete-object --bucket test-versioning-bucket --key test1.txt

# Now try listing versions
aws --endpoint-url=http://localhost:9090 s3api list-object-versions --bucket test-versioning-bucket --output json

→ This now only returns a one-liner response: 'Key'
Image

Using curl works

Using curl to enable versioning works.

# Set variables
ENDPOINT="http://localhost:9090"
BUCKET="test-versioning-bucket"

# 1. Create bucket
curl -i -X PUT "$ENDPOINT/$BUCKET/"

# 2. Enable versioning
curl -i -X PUT "$ENDPOINT/$BUCKET/?versioning" \
  -H "Content-Type: application/xml" \
  --data-binary '<VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Status>Enabled</Status></VersioningConfiguration>'

# 3. Upload multiple versions
curl -i -X PUT "$ENDPOINT/$BUCKET/example.txt" -H "Content-Type: text/plain" -d "Version 1"

# 4. Delete object (creates delete marker)
curl -i -X DELETE "$ENDPOINT/$BUCKET/example.txt"

# 5. Check for versions and delete markers
curl -X GET "$ENDPOINT/$BUCKET/?versions"

After that, this CLI command:
aws --endpoint-url=http://localhost:9090 s3api list-object-versions --bucket test-versioning-bucket --output json
returns the proper object and deleted markers.

{
    "Versions": [
        {
            "ETag": "\"d4b36e25c7ff304278d8f8203382ad65\"",
            "Size": 9,
            "Key": "example.txt",
            "VersionId": "699af213-8508-4ef1-b312-cf960839ac1a",
            "IsLatest": false,
            "LastModified": "2025-09-18T08:58:37.582000+00:00",
            "Owner": {
                "DisplayName": "s3-mock-file-store",
                "ID": "79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be"
            }
        }
    ],
    "DeleteMarkers": [
        {
            "Owner": {
                "DisplayName": "s3-mock-file-store",
                "ID": "79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be"
            },
            "Key": "example.txt",
            "VersionId": "67f3b8da-e78e-41d5-825e-ce4fd871eaa1",
            "IsLatest": true,
            "LastModified": "2025-09-18T08:58:37.582000+00:00"
        }
    ],
    "RequestCharged": null,
    "Prefix": null
}

From this, I infer that the display CLI method works but the version enabling somehow fails.

Existing Integration Tests

The integration tests in this project seem to use the AWS SDK. I suppose they work when run. The only issue seems to be the AWS CLI.

Could you look into this? 😇

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions