Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 08:30 UTC
fix(cli): exit 1 on bad input to auth-configs, tools info, triggers (#4998)
This PR: - breaking: these commands now fail with `CommandInputError` (exit 1, message on stderr, nothing on stdout, no request sent) instead of warning and exiting 0: - `dev auth-configs info` without `<id>` - `dev auth-configs create` with `--custom-credentials` that is not a JSON object - `tools info` without `<slug>` - `dev triggers create` without `<trigger-name>`, or with `--trigger-config` that is invalid JSON or not a JSON object - `dev triggers enable` without `<id>` - keeps each message and its example text; the example moves into the error message after a newline, since `cli-main.ts` prints a `CommandInputError` as plain stderr text rather than as a clack warning plus step (the `composio run` usage error already does this) - rewrites the handler and command tests that asserted the warning and exit 0: each now asserts the `commands/CommandInputError` tag, `command`, `option` and message, `isUsageFailure` (the `cli-main.ts` exit-1 path), empty output, and a repository whose every method dies; every new case fails without its fix - adds an entry under `## Unreleased` in `ts/packages/cli/CHANGELOG.md` ## Context A missing argument or malformed JSON flag is a usage error, but these five handlers returned normally, so scripts and agents that check `$?` could not tell a typo from success. When stderr is not a TTY it was worse: the old warning was clack decoration, so a piped run printed nothing at all and exited 0. The fix uses `CommandInputError` from `src/commands/errors.ts`, the error every other handler-level usage mistake already raises. `dev triggers disable` has the same missing-`<id>` path, behind its two gates; it is left for a follow-up along with the other cases below, to keep this PR to the five agreed commands. Verified on the merged head: CLI `pnpm run typecheck`, `lint:effect` (0 diagnostics), `pnpm run test` (192 files, 2071 passed; `validate:command-tests` still at 2 exemptions), `oxlint` (no findings in changed files), prettier, and root `pnpm typecheck`. Binary smoke test (`build:binary`, isolated `HOME`, fake `COMPOSIO_USER_API_KEY`, `COMPOSIO_BASE_URL=http://127.0.0.1:9`), comparing a binary built from the base with these handlers reverted against this branch: | Invocation | Before | After | | --- | --- | --- | | `dev auth-configs info` | exit 0, stderr empty when piped | exit 1, `Missing required argument: <id>` + example | | `dev auth-configs create … --custom-credentials '{bad'` / `'["x"]'` | exit 0 | exit 1, `Invalid JSON in --custom-credentials. …` + example | | `tools info` | exit 0 | exit 1, `Missing required argument: <slug>` + example | | `dev triggers create` | exit 0 | exit 1, `Missing required argument: <trigger-name>` + example | | `dev triggers create X --trigger-config '{'` / `'[1]'` | exit 0 | exit 1, `Invalid JSON in --trigger-config. …` / `--trigger-config must be a JSON object …` | | `dev triggers enable` | exit 0 | exit 1, `Missing required argument: <id>` + example | stdout was 0 bytes in every failing case. The valid invocations (`auth-configs info ac_123`, `auth-configs create` with valid JSON, `tools info GMAIL_SEND_EMAIL`, `triggers create` with a JSON object, `triggers enable trg_123`) produce byte-identical stderr and exit codes before and after (they reach the unreachable API and report it with the usual hint). Other handlers that still warn and exit 0 on invalid input, not changed here: `dev triggers disable` (no `<id>`), `dev triggers info` and `toolkits info` (no `<slug>`), `dev connected-accounts info` and `whoami` (no `<id>`), `connections remove` (selector that matches no account; #4817 owns that file), and the missing-login or missing-org checks in `orgs switch`, `dev projects list` and `init`.