Description
S3 listBuckets (emulator/s3_plugin.go:420-455) takes its request as _ *AWSRequest. It implements none of the operation's parameters and omits three of its response elements, so a caller that pages, filters or reads a bucket's Region gets an answer that ignores what it asked.
What is missing
The signature is the summary of the defect:
func (p *S3Plugin) listBuckets(_ *RequestContext, _ *AWSRequest) (*AWSResponse, error) {API_ListBuckets publishes four request parameters, all query-string:
| Parameter | Today |
|---|---|
max-buckets |
ignored — every bucket is returned |
continuation-token |
ignored — so is the pagination it implies |
prefix |
ignored — no filtering |
bucket-region |
ignored |
And the response is built from two members per bucket:
type bucketEntry struct {
Name string `xml:"Name"`
CreationDate string `xml:"CreationDate"`
}Missing: BucketRegion and BucketArn on each bucket, Owner on the result, and ContinuationToken for the paged case. Verify each against API_ListBuckets before implementing — in particular whether Owner is unconditional and what BucketArn renders for a bucket in a non-default partition.
The consequence with max-buckets is the sharper half: a caller that asks for 10 buckets and gets 500 has no way to tell that the parameter was dropped, because a short answer and a complete one are the same shape. Ignoring continuation-token is worse in a loop — the second page is identical to the first, so a paging caller either loops forever or silently processes the same buckets twice.
Note the ordering half of this is already fixed: MemoryStateManager.List now returns keys in lexicographic order, so Buckets no longer follows Go's map hash seed and two identical calls agree. API_ListBuckets documents no order, so lexicographic is substrate's reading, recorded as such in docs/services.md. Pagination needs that stable order to be correct at all, which is why the sort came first.
Acceptance criteria
-
max-bucketsbounds the result, with AWS's documented range and default verified from the API reference, not assumed. -
continuation-tokenpages over the lexicographic key order, andContinuationTokenis returned when and only when the result was truncated — matching how the existing S3 listings emit their cursors. -
prefixfilters by bucket-name prefix. -
bucket-regionfilters by the bucket's Region. This needs the Region to be stored atCreateBucketif it is not already, which is the one non-trivial part of this issue. - Each bucket carries
BucketRegionandBucketArn; the result carriesOwner. - Behavioural tests through
StartTestServerand real wire calls, per the standing rule that a helper writing state directly cannot prove a value is readable through the owning service's own call: ≥8 buckets created over the wire, thenmax-buckets=3returning 3 with a token, the token returning the next 3 with no repeat and no omission,prefixselecting only its own, andbucket-regionselecting only buckets created in that Region. -
docs/services.mdrecords which parameters are honoured and whatOwnerreports, since substrate has no account-owner concept beyond the account ID.
Found while auditing .List( call sites for the v0.116.0 ordering fix.
Activity
scttfrdmn commentedon Sep 15, 2026
Implemented in #905. Two premises in the body did not survive verification against the tree and the AWS reference, so they were implemented as the documentation says rather than as written here.
1. The Region was already stored. The acceptance criterion says
bucket-region"needs the Region to be stored atCreateBucketif it is not already, which is the one non-trivial part of this issue." It was already stored:createBuckethas always persistedS3Bucket.RegionfromreqCtx.Region. The filter reads a value substrate has held all along, and the part flagged as non-trivial turned out not to exist.2.
BucketArnis deliberately not implemented. The criterion "Each bucket carriesBucketRegionandBucketArn" is half wrong, and theBuckettype page is what rules it out.API_Bucketsays ofBucketArn: "This parameter is only supported for S3 directory buckets."API_ListBucketsopens with: "This operation is not supported for directory buckets." So the one operation that renders aBucketcan never be looking at a bucket the member applies to, and noListBucketsresponse AWS produces carries aBucketArn. Synthesizing a general purpose bucket ARN would hand a consumer a field readable against substrate and empty against AWS — worse than a missing one. The issue asked for it on the strength of its appearing in theBuckettype, which was a reasonable read of the type page's contents list but not of its prose.A related detail the issue did not mention:
BucketRegionis conditional, not unconditional.API_Bucket: "If the request contains at least one valid parameter, it is included in the response." AWS's own examples bear this out — the unpaginated Example 1 shows noBucketRegion, and Examples 2–5, each of which passes a parameter, all show one. This is implemented as documented, which has a happy side effect on compatibility: an unparameterised listing renders exactly what it rendered before, soOwneris the only addition an existing caller sees.One thing that could not be sourced.
API_ListBucketspublishes noErrorssection, and the S3ErrorResponsesreference returns an effectively empty body to automated retrieval, so nothing confirms what AWS returns for an out-of-rangemax-bucketsor an undecodable token.InvalidArgument/400 is substrate's reading, labelled as unverified in the code comment,docs/services.mdandCHANGELOG.md. Refusing rather than clamping is deliberate and on this issue's own reasoning: silently substituting a value the caller did not ask for is invisible in a well-formed response, which is exactly what made the original defect undetectable.Everything else in the body checked out, including the
emulator/s3_plugin.go:420-455line reference and the note that the lexicographic ordering from #865 is what pagination had to be built on.fix(s3): ListBuckets honours its four request parameters (#884) (#905)