Skip to content

fix(s3): GetObject/HeadObject return 404/405 for delete markers (#318)#319

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/318-getobject-delete-marker
Jun 6, 2026
Merged

fix(s3): GetObject/HeadObject return 404/405 for delete markers (#318)#319
scttfrdmn merged 1 commit into
mainfrom
fix/318-getobject-delete-marker

Conversation

@scttfrdmn
Copy link
Copy Markdown
Owner

Follow-up to #316 (ListObjectsV2 delete-marker fix). Found via Fatou.jl integration tests.

Problem

getObject already returned 404 for a delete-marker current version, but two gaps remained, and headObject had no delete-marker handling at all:

  1. GET naming the delete-marker version returned 404 NoSuchKey; per the S3 API it should be 405 MethodNotAllowed.
  2. Neither path emitted x-amz-delete-marker: true, so SDKs couldn't distinguish a deleted object from a never-existed key.
  3. HeadObject had no IsDeleteMarker check (and ignored versionId) — HEAD on a deleted key returned 200 with marker metadata.

Fix

New s3DeleteMarkerResponse helper centralizes AWS-accurate behaviour:

  • delete-marker current version → 404 NoSuchKey + x-amz-delete-marker: true
  • request naming the marker version → 405 MethodNotAllowed + x-amz-delete-marker: true + Allow

getObject uses it; headObject is now version-aware and applies the same check.

Verification

New TestS3_GetHeadObject_DeleteMarker covers all three paths (plain GET 404+header, HEAD 404, versioned GET 405). make lint clean; full S3 suite green. AWS semantics verified against the S3 GetObject API reference.

Closes #318

Follow-up to #316. getObject already 404'd a delete-marker current version,
but two gaps remained, both found via Fatou.jl integration tests:

- GET naming the delete-marker version returned 404 NoSuchKey; AWS returns
  405 MethodNotAllowed. Neither path emitted the x-amz-delete-marker header.
- headObject had no IsDeleteMarker check at all (and ignored versionId), so
  HEAD on a deleted key returned 200 with marker metadata.

New s3DeleteMarkerResponse helper centralizes the AWS-accurate behaviour:
404 NoSuchKey for a delete-marker current version, 405 MethodNotAllowed when a
version is named, both with x-amz-delete-marker: true (+ Allow on the 405).
headObject is now version-aware and applies the same check.

Regression test TestS3_GetHeadObject_DeleteMarker covers all three paths.
make lint clean; full S3 suite green.

Closes #318
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 6, 2026

Codecov Report

❌ Patch coverage is 93.10345% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/s3_plugin.go 93.10% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn scttfrdmn merged commit 8971141 into main Jun 6, 2026
10 checks passed
@scttfrdmn scttfrdmn deleted the fix/318-getobject-delete-marker branch June 6, 2026 02:20
@scttfrdmn scttfrdmn mentioned this pull request Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S3 GetObject should return 404 MethodNotAllowed for delete markers (follow-up to #316)

1 participant