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): print an unmatched `--account` as a usage error, not a crash (#5003)
> Stacked on #5002 (base `fix/cli-execute-failure-exit-code`). It reuses the fake backend/Dashboard subprocess harness that #5002 adds to `test/src/cli-main.test.ts`. Retarget to `next` after #5002 merges. This PR: - Adds `ConnectedAccountResolutionError` to the existing `UsageFailure` union (`src/commands/errors.ts`). An `--account` that matches no connected account now prints as one plain line on stderr and exits 1, with nothing on stdout, like `CommandInputError` / `NotLoggedInError` / `ProjectResolutionError`. - Applies to `composio execute` and `composio proxy`, which both resolve `--account` through `resolveConnectedAccountForToolkit`. A failure to load the toolkit's connected accounts uses the same path. - Updates the `UsageFailure` notes in `ts/packages/cli/AGENTS.md`, the `cli-command` skill reference, and the comment in `cli-main.ts`. - Adds a subprocess test and a CHANGELOG entry. ## Context `composio execute GMAIL_FETCH_EMAILS --account does-not-exist-xyz -d '{}'` printed a good message under a crash banner: ``` 💥 services/ConnectedAccountResolutionError • No connected account matched "does-not-exist-xyz" for toolkit "gmail". No active connected accounts were found for that toolkit. ◯ ╰─ composio-cli at jKt (/$bunfs/root/composio:1178:10294) ``` `cli-main.ts` already has one path for expected failures (`isUsageFailure`), so this PR adds the error to that union instead of adding a special case. It joins the union as a whole, the way `ProjectResolutionError` (including its `request_failed` reason) already does. Verification: - New test in `test/src/cli-main.test.ts` spawns `src/bin.ts` against the local fake backend. It asserts exit 1, empty stdout, and stderr equal to the one-line message, with no `💥`, error tag, or `composio-cli` span. With the `errors.ts` change reverted it fails (`expected '💥 services/ConnectedAccountResoluti…'`). - Ran CLI `pnpm run test` (2203 passed; `validate:command-tests` still has 2 exemptions), `pnpm run typecheck`, `lint:effect`, oxlint, prettier, and root `pnpm typecheck`. - Built the binary from `origin/next` and from this branch and ran both with an isolated HOME and a fake `uak_` key against a local fake server: - `next`, `execute … --account does-not-exist-xyz`: exit 1, stderr is the banner and stack shown above. - This branch, same command: exit 1, empty stdout, stderr is only `No connected account matched "does-not-exist-xyz" for toolkit "gmail". No active connected accounts were found for that toolkit.` - `proxy … --toolkit gmail --account does-not-exist-xyz`: same before and after as `execute`.