Skip to content

fix(r2): local object listing ignores --start-after #17039

Open

Description

@coygeek

Summary

cf r2 objects list --local --start-after first succeeds and includes first. A local script that resumes a listing from a saved key can process that key twice.

Steps to reproduce

Use the CLI described under Runtime or environment. Run these commands in a new temporary directory. They use a disposable local R2 bucket and require no Cloudflare credentials.

cf r2 objects put first --body sample --bucket-name sample-bucket --local --persist-to state
cf r2 objects put second --body other --bucket-name sample-bucket --local --persist-to state
cf r2 objects list --start-after first --bucket-name sample-bucket --local --persist-to state

Expected behavior

The listing contains only objects whose keys sort after first. If local mode does not offer this filter, the CLI gives an explicit unsupported-option error before emitting a successful listing.

Actual behavior

Both CLI builds exited 0 and returned first and second in the JSON array. A control that requested a single object and reused its reported cursor returned only second on the next page.

Runtime or environment

  • macOS 27.2 arm64, Node.js 26.13.1, npm 12.2.2.
  • Published cf 1.0.0-rc.1 and the current main CI package, both with bundled Miniflare 5.20261117.0-beta. The CLI transport at that revision forwards the API query to Local Explorer.
  • A separate direct probe of the Local Explorer endpoint on Miniflare 5.20261118.0-beta also returned both keys with start_after=first.

Evidence

  • Expected source: cf r2 objects list --help describes --start-after as the lower key boundary, and the List Objects API reference defines start_after for lexicographic continuation.
  • Failure source: The command sequence above returns both keys with status 0. The Local Explorer implementation handles prefix, delimiter, cursor, and page size. Its narrower listing support is consistent with the direct endpoint result.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

Restoration check

With the same bucket contents, request a listing after first. A successful response contains only second. If the combination remains unsupported, the command exits nonzero and identifies --start-after as unavailable in local mode. Cursor pagination still succeeds.

Triage assessment

  • Impact level: P2
  • Assessment status: supported
  • Impact basis: An accepted filter returns extra rows under local simulation, which can hide incorrect resume behavior in scripts.
  • Workaround status: available
  • Workaround basis: In the same local bucket, paginating from the beginning and reusing a cursor advanced past the boundary correctly.

Activity

  1. workers-devprod commented on Nov 19, 2026

    @workers-devprod
    Contributor

    Automated triage

    Issue assessment

    • Actionability: ✅ Actionable.
    • Type: Bug.
    • Reproduction: Automatic attempt requested.
    • Labels:
      • bug (high)
      • product:r2 (high)
      • package:miniflare (high)
      • feature:local-explorer (high)
    Actionability and missing information

    Local R2 listing silently ignores --start-after despite it being documented as a lower key boundary; a credential-free local reproduction returns both keys with exit 0 and a direct Miniflare endpoint probe reproduces it; report includes versions, steps, expected and actual behavior.

    Reproduction reason: The report gives concrete credential-free commands with a persistent local bucket and a direct Miniflare endpoint probe showing local listing returning keys at or before the start-after boundary, so reproduction can be attempted.

    Reproduction

    • Result: ✅ Reproduced.
    • Summary: Reproduced on miniflare 5.20261118.0-beta (workerd 1.20261118.1): Local Explorer R2 listing returned both 'first' and 'second' with HTTP 200 when queried with start_after=first, matching the issue; cursor pagination control resumed correctly. Artifacts in /workspace/reproduction-output.
    Evidence and attempted steps

    Steps attempted:

    1. Cloned cloudflare/workers-sdk and identified the surface: the CLI's local runtime forwards local R2 queries to Miniflare's Local Explorer (local-explorer/resources/r2.ts, listR2Objects) at /cdn-cgi/local/explorer/api. Repo miniflare version 5.20261118.0-beta matches the issue's probe.
      • Command: git clone --depth 50 https://github.com/cloudflare/workers-sdk.git /workspace/workers-sdk
    2. Created a minimal package-only project pinning miniflare 5.20261118.0-beta (published from the repo, bundled Local Explorer) and installed with pnpm to preserve resolved versions in the lockfile.
      • Command: cd /workspace/reproduction-output/project && pnpm install --no-frozen-lockfile
    3. Ran the reproduction: Miniflare with unsafeLocalExplorer and a sample-bucket R2 binding; PUT 'first'/'second' via the explorer API, then listed with and without start_after=first plus a per_page=1 cursor control. Identical across runs and a clean-copy re-run; exit 10 = REPRODUCED verdict.
      • Command: cd /workspace/reproduction-output/project && node reproduce.mjs

    Expected behavior: The local listing requested after first (CLI --start-after, forwarded by the CLI's local runtime to Miniflare's Local Explorer) should contain only keys sorting strictly after "first" (i.e. only "second"), or fail loudly identifying the option as unsupported in local mode.

    Observed behavior: GET /cdn-cgi/local/explorer/api/r2/buckets/sample-bucket/objects?start_after=first returned HTTP 200 with BOTH keys "first" and "second" — identical to the unfiltered baseline listing. The option is silently dropped (the endpoint's query schema accepts only prefix/delimiter/cursor/per_page). Control: per_page=1 plus the returned cursor returned only "second" on the next page, matching the issue's control observation and proving cursor pagination works while start_after is ignored.

    Artifact: Download reproduction archive (Cloudflare Access required).

    Treat archive contents as untrusted. Inspect them before running anything.


    This summary was generated by an LLM and may contain errors. Please verify its findings.

    Triage bot commands and options

    Repository collaborators with write or admin access can trigger actions by commenting on this issue:

    • @workers-devprod reproduce: Attempt to reproduce the issue using its description and recent comments.
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

    bugfeature:local-explorerRelating to the Local Explorer dashboard & APIpackage:miniflareRelating to Miniflareproduct:r2Relating to Cloudflare R2: https://developers.cloudflare.com/r2/

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ 换网址