Repository navigation
Description
Summary
DeleteBucket removes only the bucket:<name> state entry. Every bucket sub-resource
substrate stores under its own key survives, so creating a bucket, configuring it,
deleting it and creating it again yields a bucket that reports the deleted bucket's
configuration.
Found while implementing #470, which made CreateBucket write bucket_acl:<bucket> —
and therefore made the create authoritative for that one key, since a create that names
no ACL now clears any entry left behind. The other sub-resources have no such clear.
The surviving keys
deleteBucket (emulator/s3_plugin.go) deletes bucket:<name> and nothing else. These
keys are all bucket-scoped and all outlive it:
| Key | Written by | Observable through |
|---|---|---|
bucket_policy:<bucket> |
PutBucketPolicy |
GetBucketPolicy |
public_access_block:<bucket> |
PutPublicAccessBlock |
GetPublicAccessBlock, and enforced on PutObject/PutBucketAcl/PutObjectAcl/PutBucketPolicy |
bucket_tagging:<bucket> |
PutBucketTagging |
GetBucketTagging |
bucket_versioning:<bucket> |
PutBucketVersioning |
GetBucketVersioning, and changes the write path |
bucket_notification:<bucket> |
PutBucketNotificationConfiguration |
GetBucketNotificationConfiguration, and dispatches on write |
bucket_lifecycle:<bucket> |
PutBucketLifecycleConfiguration |
GetBucketLifecycleConfiguration |
(bucket_acl:<bucket> is no longer on this list as of #470.)
Why it matters more than a leak
Three of these change behaviour rather than just a GET response:
- A recreated bucket inherits the deleted bucket's Block Public Access configuration,
so aPutObject --acl public-readthat should succeed against a fresh bucket is
refused with 403AccessDenied. That is substrate refusing what real AWS accepts —
the defect shape the tracker keeps returning to, here caused by leftover state rather
than by a missing model. - A recreated bucket inherits versioning, so a
PutObjectwrites a versioned object
and returns anx-amz-version-idthe consumer never enabled versioning for. - A recreated bucket inherits notification configurations, so a write fires a
notification to a queue or function the new bucket was never wired to.
The natural shape of a fixture makes this easy to hit: a test that tears down and
recreates a bucket between cases is the common case, not an exotic one.
What real S3 does
A bucket is a namespace, and every sub-resource is scoped to it. A deleted bucket's
configuration does not survive — a recreated bucket of the same name starts with no
policy, no BPA configuration, no tagging, no versioning, no notifications and no
lifecycle rules. Object ACLs and the objects themselves cannot survive either, since
DeleteBucket requires the bucket be empty.
Acceptance criteria
-
DeleteBucketclears every bucket-scoped key listed above. - Recreate-after-delete: create → configure (each of the six) → delete → create →
each GET reports the unconfigured default. - The BPA case asserted through behaviour, not just through
GetPublicAccessBlock:PutObject --acl public-readagainst the recreated bucket
succeeds. - The versioning case asserted through behaviour: a
PutObjectagainst the recreated
bucket returns nox-amz-version-id. - Decide and record whether the deletes are best-effort (
_ = p.state.Delete(...),
matchingdeleteObject's existing style) or must be propagated — a partial delete
that leaves one key behind is the bug this issue is about, so silence is a
questionable default here. -
emulator/s3_plugin.go'ss3CreateBucketACLdoc comment updated: it currently
cites this issue as the reason the other sub-resources still leak.
Activity
scttfrdmn commentedon Aug 3, 2026
Milestoned to v0.89.0, deliberately alongside #518 (CloudFormation
DeleteStackdoes not delete the stack's resources) rather than on its own.Why they are paired. #518 adds a delete dispatcher that will call
DeleteBucketfor everyAWS::S3::Bucketin a stack. Whatever this issue leaves behind, that sweep inherits — and it inherits it in the shape that hurts most: a consumer's test deletes a stack, redeploys it with the same bucket name, and the "new" bucket silently arrives carrying the deleted stack's versioning, lifecycle, policy, CORS and encryption configuration. That is the same defect class as the rest of the v0.87.x CloudFormation work — a caller's observation is wrong while every call returns success — and it is much easier to hit through a stack lifecycle than through a hand-writtenDeleteBucket.Fixing the sweep first would just make this leak reachable from a new path, so the ordering is: this, then the sweep.
No change to the issue's own analysis. Filing this comment so the pairing is recorded rather than being a coincidence of milestone.
test(s3): cover the propagation paths DeleteBucket's clear depends on (…
fix(s3): DeleteBucket clears the bucket's namespace (#508) (#543)