Skip to content

S3 ListBuckets implements none of its request parameters and omits Owner, BucketArn and BucketRegion #884

Closed

Description

@scttfrdmn

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-buckets bounds the result, with AWS's documented range and default verified from the API reference, not assumed.
  • continuation-token pages over the lexicographic key order, and ContinuationToken is returned when and only when the result was truncated — matching how the existing S3 listings emit their cursors.
  • prefix filters by bucket-name prefix.
  • bucket-region filters by the bucket's Region. This needs the Region to be stored at CreateBucket if it is not already, which is the one non-trivial part of this issue.
  • Each bucket carries BucketRegion and BucketArn; the result carries Owner.
  • Behavioural tests through StartTestServer and 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, then max-buckets=3 returning 3 with a token, the token returning the next 3 with no repeat and no omission, prefix selecting only its own, and bucket-region selecting only buckets created in that Region.
  • docs/services.md records which parameters are honoured and what Owner reports, 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

  1. added
    type: bug
    on Sep 15, 2026
  2. added this to the v0.117.0 milestone on Sep 15, 2026
  3. scttfrdmn commented on Sep 15, 2026

    @scttfrdmn
    OwnerAuthor

    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 at CreateBucket if it is not already, which is the one non-trivial part of this issue." It was already stored: createBucket has always persisted S3Bucket.Region from reqCtx.Region. The filter reads a value substrate has held all along, and the part flagged as non-trivial turned out not to exist.

    2. BucketArn is deliberately not implemented. The criterion "Each bucket carries BucketRegion and BucketArn" is half wrong, and the Bucket type page is what rules it out. API_Bucket says of BucketArn: "This parameter is only supported for S3 directory buckets." API_ListBuckets opens with: "This operation is not supported for directory buckets." So the one operation that renders a Bucket can never be looking at a bucket the member applies to, and no ListBuckets response AWS produces carries a BucketArn. 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 the Bucket type, 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: BucketRegion is 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 no BucketRegion, 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, so Owner is the only addition an existing caller sees.

    One thing that could not be sourced. API_ListBuckets publishes no Errors section, and the S3 ErrorResponses reference returns an effectively empty body to automated retrieval, so nothing confirms what AWS returns for an out-of-range max-buckets or an undecodable token. InvalidArgument/400 is substrate's reading, labelled as unverified in the code comment, docs/services.md and CHANGELOG.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-455 line reference and the note that the lexicographic ordering from #865 is what pagination had to be built on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions