Skip to content

cli: five option validators throw TypeError (AB5000, exit 1) where Commander's InvalidArgumentError (exit 2) is used elsewhere #598

Description

@ScriptedAlchemy

Split out of the #590 docsite audit (reference/cli.mdx exit-code table). The docs now state current behaviour; this issue tracks whether the code should change.

In packages/agent-bundle/src/cli.ts, option-argument validators are inconsistent about how they fail:

Validator Throws Result
mcpAppProfile (serve-app --profile) InvalidArgumentError Commander error → exit 2
consentCapability (serve-app --allow) InvalidArgumentError exit 2
doctorHost (doctor --host) InvalidArgumentError exit 2
port (--port) TypeError rethrown by Commander → generic catch → one AB5000 diagnostic on stderr, exit 1
trialCount (--trials) TypeError AB5000, exit 1
installHost (dev --install-host) TypeError AB5000, exit 1
installMode (install/uninstall --mode) TypeError AB5000, exit 1
installScope (install/uninstall --scope) TypeError AB5000, exit 1

(parseJsonObject for --input/--input-file also throws TypeErrorAB5000, exit 1; that one is arguably a runtime input failure rather than a parser failure and may be fine as is.)

A bad option value is a usage error like an unknown option, so the five TypeError validators should probably throw InvalidArgumentError so Commander prints error: option '--port <port>' argument 'x' is invalid. Port must be a TCP port number. and the process exits 2 — matching --profile/--allow/--host. Tests in packages/agent-bundle/tests/** that assert the AB5000 shape for these would need updating, and website/docs/{en,zh}/reference/cli.mdx exit-code rows (updated in #590 to describe today's split) would move those options to the exit-2 row.

Deliberately not done in the #590 docs PR to keep that change docs-only.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions