Skip to content

[wrangler] fix: suppress status badge when printBanner returns false#13837

Merged
jamesopstad merged 4 commits into
cloudflare:mainfrom
matingathani:fix/beta-banner-respects-print-banner
May 12, 2026
Merged

[wrangler] fix: suppress status badge when printBanner returns false#13837
jamesopstad merged 4 commits into
cloudflare:mainfrom
matingathani:fix/beta-banner-respects-print-banner

Conversation

@matingathani
Copy link
Copy Markdown
Contributor

Fixes #13121.

When a command sets printBanner: (args) => !args.json (e.g. ai-search list), the deprecated/status-message badge was still printed in JSON mode because the statusMessage guard didn't check the same condition as the banner guard.

Root cause: def.metadata.statusMessage was gated only by !getWranglerHideBanner(), not by the command's printBanner logic.

Fix: Extract bannerEnabled from the printBanner evaluation and gate the statusMessage display behind it, mirroring the existing printWranglerBanner() call.


  • Tests
    • Tests included/updated
  • Public documentation
    • Documentation not necessary because: this is a bug fix for an internal guard condition, no user-facing docs change required

Copilot AI review requested due to automatic review settings May 7, 2026 00:30
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

🦋 Changeset detected

Latest commit: 84c3e07

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

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

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

@workers-devprod workers-devprod requested review from a team and jamesopstad and removed request for a team May 7, 2026 00:30
@workers-devprod
Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/fix-beta-banner-respects-print-banner.md: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/ai-search.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/core/register-yargs-command.ts: [@cloudflare/wrangler]

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an inconsistency in Wrangler’s command handler so that a command’s behaviour.printBanner decision (e.g. disabling banners for --json) also suppresses the beta/open-beta statusMessage, preventing unexpected non-JSON output on stderr.

Changes:

  • Compute a single bannerEnabled boolean from behaviour.printBanner and reuse it consistently.
  • Gate def.metadata.statusMessage printing behind bannerEnabled (in addition to getWranglerHideBanner()).
  • Add a regression test ensuring the beta/open-beta status warning is not printed for ai-search list --json.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/wrangler/src/core/register-yargs-command.ts Reuses the printBanner evaluation to consistently suppress the beta/open-beta status warning when banners are disabled.
packages/wrangler/src/tests/ai-search.test.ts Adds a regression test asserting the status warning doesn’t appear in --json mode.
.changeset/fix-beta-banner-respects-print-banner.md Records the patch-level bugfix in the release notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@matingathani
Copy link
Copy Markdown
Contributor Author

@NuroDev @penalosa @dario-piotrowicz — all Copilot review comments have been addressed. This PR is ready for review.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 7, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 84c3e07

matingathani and others added 2 commits May 9, 2026 23:41
…ning false

When printBanner is the static boolean `false` (e.g. kv bulk get), the
statusMessage (open-beta warning) should still be shown. Only suppress it
when printBanner is a dynamic function that returned false (e.g. --json mode).
@jamesopstad
Copy link
Copy Markdown
Contributor

/bonk review this PR

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

Clean, minimal fix for the reported issue. The logic is correct and the distinction between static false and dynamic function-returning-false is well-reasoned.

A couple of minor observations below, but nothing blocking.

Comment thread packages/wrangler/src/core/register-yargs-command.ts
Comment thread packages/wrangler/src/__tests__/ai-search.test.ts
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 11, 2026

Review submitted. Here's a summary of my findings:

Overall verdict: Approve. This is a clean, well-scoped bug fix.

What the PR does: When a command defines printBanner: (args) => !args.json (like ai-search list), the status message (e.g. "open beta" warning) was still printed in --json mode because statusMessage wasn't gated by the same condition as the banner. The fix extracts a bannerEnabled boolean and uses it to suppress the status message when the dynamic printBanner function returns false.

Key design decision: The PR intentionally only suppresses statusMessage when printBanner is a function that returned false (the --json case). When printBanner is the static boolean false, status messages are still shown — this preserves existing behavior for commands like tunnel list (experimental) and kv bulk get (open beta) that use printBanner: false.

Two minor comments posted:

  1. A suggestion to reframe the code comment to say "preserves existing behavior" rather than implying the static false commands intentionally want status warnings shown.
  2. A note that the test assertion not.toContain("open beta") on std.warn could be made slightly more resilient with not.toMatch(), though it's fine as-is.

github run

@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented May 12, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

Copy link
Copy Markdown
Contributor

@jamesopstad jamesopstad left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Copy link
Copy Markdown
Contributor

@workers-devprod workers-devprod left a comment

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk May 12, 2026
@jamesopstad jamesopstad merged commit b0cee1d into cloudflare:main May 12, 2026
55 of 57 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[wrangler] Beta status banner is printed even when printBanner is set to false

4 participants