From c2911adc8d441b1c54f79237f753f1a9e5fa8dca Mon Sep 17 00:00:00 2001 From: James Varah <31836482+jvarah@users.noreply.github.com> Date: Thu, 19 Nov 2026 16:03:36 +0000 Subject: [PATCH] fix(cli): report an empty catalog --type= as a usage error (#8130) `catalog --type=` passed an empty string, which the truthiness check read as no filter: it listed every item and exited 0. Any given value other than block or component is now a usage error (exit 2), as #7669 made it for other bad values. Follow-up to #7678 review. Claude-Session: https://claude.ai/code/session_01M3Xbw44WYGyVqg4AjkzFxj Co-authored-by: Claude --- packages/cli/src/cli.agentMode.test.ts | 1 + packages/cli/src/commands/catalog.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/cli.agentMode.test.ts b/packages/cli/src/cli.agentMode.test.ts index 2e293528aa..f67bfa4237 100644 --- a/packages/cli/src/cli.agentMode.test.ts +++ b/packages/cli/src/cli.agentMode.test.ts @@ -235,6 +235,7 @@ describe("agent-mode contract", () => { ["compare a.html b.html --timeout -1", "--timeout must be a positive integer"], ["grade-compare --for frame.png", "Exactly one of --grades or --luts"], ["catalog --type widget", 'Invalid --type: "widget". Use "block" or "component".'], + ["catalog --type=", 'Invalid --type: "". Use "block" or "component".'], ["check --range 5,1", "Invalid --range"], ["check --samples ten", "Invalid --samples"], ["check --tolerance=-1", "Invalid --tolerance"], diff --git a/packages/cli/src/commands/catalog.ts b/packages/cli/src/commands/catalog.ts index 70bc3fa812..8c50d4f302 100644 --- a/packages/cli/src/commands/catalog.ts +++ b/packages/cli/src/commands/catalog.ts @@ -225,7 +225,8 @@ export default defineCommand({ let typeFilter: ItemType | undefined; if (args.type === "block") typeFilter = "hyperframes:block"; else if (args.type === "component") typeFilter = "hyperframes:component"; - else if (args.type) { + // An empty `--type=` is a typo too, not a request for no filter. + else if (args.type !== undefined) { throw new CliUsageError(`Invalid --type: "${args.type}". Use "block" or "component".`); }