Skip to content

Conversation

@NuroDev
Copy link
Contributor

@NuroDev NuroDev commented Jan 22, 2026

Fixes #11823

Before

➜ wrangler foo --help
wrangler

COMMANDS
  wrangler docs [search..]        πŸ“š Open Wrangler's command documentation in your browser

After

➜ wrangler foo --help

✘ [ERROR] Unknown argument: foo

wrangler

COMMANDS
  wrangler docs [search..]        πŸ“š Open Wrangler's command documentation in your browser

Before

➜ ❯ wrangler types --hello

✘ [ERROR] Unknown argument: hello


wrangler

COMMANDS
  wrangler docs [search..]        πŸ“š Open Wrangler's command documentation in your browser

After

➜ wrangler types --hello

✘ [ERROR] Unknown argument: hello


wrangler types [path]

πŸ“ Generate types from your Worker configuration

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: Minor bug fix

A picture of a cute animal (not mandatory, but encouraged)

Screenshot 2026-01-22 at 3 38 35β€―pm
Open with Devin

@NuroDev NuroDev self-assigned this Jan 22, 2026
@changeset-bot
Copy link

changeset-bot bot commented Jan 22, 2026

πŸ¦‹ Changeset detected

Latest commit: 5f7cdff

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 22, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12050

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12050

miniflare

npm i https://pkg.pr.new/miniflare@12050

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12050

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12050

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12050

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12050

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12050

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12050

wrangler

npm i https://pkg.pr.new/wrangler@12050

commit: 5f7cdff

@NuroDev NuroDev changed the title Added initial invalid command / flag fix Fixed Wrangler invalid command / argument error logging Jan 22, 2026
@NuroDev NuroDev marked this pull request as ready for review January 22, 2026 15:57
@NuroDev NuroDev requested a review from a team as a code owner January 22, 2026 15:57
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View issue and 5 additional flags in Devin Review.

Open in Devin Review

if (hasHelpFlag && subCommand) {
const knownCommands = registry.topLevelCommands;
if (!knownCommands.has(subCommand)) {
logger.info("");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is here simply to appease formatting to match other errors by adding a spacing around the error.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View issue and 5 additional flags in Devin Review.

Open in Devin Review

* Set of legacy command names registered outside the `CommandRegistry` class.
* Used to track commands like `containers`, `pubsub`, etc.
*/
#legacyCommands: Set<string>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't they all be moved to the registry ?

Copy link
Contributor Author

@NuroDev NuroDev Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most commands are registered with the registry, but a handful of others still use the wrangler.command(...) system and we need to aggregate them both into a single source of truth.

To keep this PR simple(r) and not break anything I didn't want to move them to the registry yet. It could be simple, but I'm still not extremely well versed in the CLI setup to know if legacy commands require something that the registry doesn't?

Copy link
Contributor

@vicb vicb Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a similar question on a PR from TK yesterday.

My opinion is that we should stop adding things in the wrong way(TM) and refactor first - unless there is an urgent need to do otherwise.

Having different code paths is also something that also impacts the other PR.

+100 to refactor before doing more changes that will make the needed refactor harder later.

/cc @MattieTK @petebacondarwin

edit: I think the following somehow proves my point:

I'm still not extremely well versed in the CLI setup to know if legacy commands require something that the registry doesn't?

Yes the current code is too complex.
What we should do is to simplify/unify it instead of making if more complex for the next one that will debug/edit it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NuroDev
Copy link
Contributor Author

NuroDev commented Jan 23, 2026

Spoke with @petebacondarwin yesterday about this and I'm going to put this PR on hold until #12055 is merged so this fix doesn't have to rely on legacy commands.

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

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

Unknown Wrangler commands skip error messaging with a flag

2 participants