Skip to content

cli: --dry-run ignores --local, prints remote api.cloudflare.com URL and misses unsupported-local errors #717

Open

Description

@MattieTK

Summary

Passing --local together with --dry-run ignores --local. --dry-run always prints the remote https://api.cloudflare.com/client/v4/... URL with no indication that the command will run locally, and succeeds even for commands that reject --local at runtime (such as cf d1 query or cf queues list).

Because --dry-run is the documented way for users and agents to preview what a command will do before running it, showing a remote api.cloudflare.com URL makes --local look ignored or unsupported.

Expected behaviour

When --local and --dry-run are combined:

  1. Commands that support local execution should indicate local targeting and state path in the --dry-run JSON instead of printing a remote api.cloudflare.com URL:
{
  "command": "cf workflows list",
  "local": true,
  "persistTo": ".cloudflare/state",
  "method": "GET",
  "path": "/workflows",
  "pathParams": {},
  "query": {},
  "bodyKind": "none"
}
  1. Commands that have no local equivalent should fail during --dry-run with the same error they produce without --dry-run:
┌ Error
│ This command has no local equivalent. Re-run without --local to use the Cloudflare API.
└

Reproduction

  1. Locally supported command:
cf workflows list --local --dry-run

Actual output (prints the remote API URL even though cf workflows list --local --persist-to <dir> executes locally):

{
  "command": "cf workflows list",
  "method": "GET",
  "url": "https://api.cloudflare.com/client/v4/accounts/<account-id>/workflows",
  "pathParams": {},
  "query": {},
  "bodyKind": "none"
}
  1. Command without local support:
cf d1 query 00000000-0000-0000-0000-000000000000 --sql "SELECT 1" --local --dry-run

Actual output: exits 0 and prints POST https://api.cloudflare.com/client/v4/accounts/<account-id>/d1/database/.../query, whereas running the same command without --dry-run fails with:

┌ APIError
│ [error] This command has no local equivalent. Re-run without --local to use the Cloudflare API. The local explorer API does not implement POST /d1/database/00000000-0000-0000-0000-000000000000/query.
│ 404 Not Found
└

Environment

  • cf: 1.0.0-rc.2
  • Node.js: 24.22.3
  • OS: macOS 26.7.3 (arm64)

Activity

  1. added
    bug
    on Nov 20, 2026
  2. added this to the cf GA milestone on Nov 30, 2026
  3. MattieTK commented on Dec 1, 2026

    @MattieTK
    MemberAuthor

    Related to #857 and #861: those also describe --dry-run output that differs from what the command sends (a kebab-case field name in the multipart body in #857, and a query parameter shown but not sent in #861).

  4. darrellchee commented on Dec 2, 2026

    @darrellchee

    I have a fix for this on my fork: main...darrellchee:cf:fix/issue-717

    With --local, generated --dry-run previews now print the local target ("local": true, "persistTo", and the explorer "path") instead of the remote api.cloudflare.com URL. Commands with no local equivalent now fail during the dry run with the same "This command has no local equivalent" error as the real run. To decide that, the dry run asks Miniflare's own local explorer router in a throwaway, isolated session (temp state, no dev registry, no shared storage), so it matches the real run without copying a route list into cf and without touching project state. It does not use the explorer's OpenAPI document, which lists GET /r2/buckets/{bucket_name} even though that route is not implemented.

    Most of the diff is regenerated command files. The change is in generator/plugin/emit/handler.ts, and regenerating changes 3 lines in each of the 2,977 generated commands. The hand-written part is in lib/dry-run.ts, lib/local-runtime.ts and lib/local.ts, with tests.

    I saw that PRs need a vouch during the RC phase. If you want this change, could a maintainer vouch for darrellchee so I can open the PR?

    Before and after:

    compare.mp4
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

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions