Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(cli): treat empty stored api keys and list shape skew as failures (#5029)
This PR: - fixes the two behavior findings from the post-merge audits of #4994 and #4995 (both were merged before their reviews finished, so these land as follow-ups on `next`) - `orgs switch` now fails with `commands/NotLoggedInError` (exit 1, nothing written) when the stored `api_key` is `""` — `requireLogin` counts an empty key as logged in (`Option.isSome`), so the handler's `Effect.fromOption(ctx.data.apiKey, notLoggedIn)` let the command proceed where the pre-move handler warned and changed nothing; `Option.filter` rejects the empty key before any work happens - `dev connected-accounts list` now fails with `commands/ConnectedAccountsListRequestError` when the decode fallback returns a payload whose `items` is not an array — the `Arr.match` rewrite had turned that case into a silent "No connected accounts found." + exit 0 (the pre-move code crashed on `.map` instead), so a piped consumer could read "zero accounts" while data was present - restores the three `@example` JSDoc blocks the #4994 move dropped from the `connected-accounts` cmd files - adds regression tests: a stored-empty-key cmd test asserting `NotLoggedInError` and an untouched `user_data.json`, and a raw shape-skew handler test asserting the failure instead of an empty listing ## Context Found by the post-merge reviews of the CLI command-layout series: #4995's empty-key divergence (P2, validator-confirmed under `authorization-authentication`) and #4994's decode-fallback shape-skew drift (P3) plus its dropped JSDoc (P3). Validation narrowed the empty-key trigger: blank `COMPOSIO_USER_API_KEY` env values are trimmed upstream (`src/config/env.ts`), so the surviving precondition is an empty key already in `user_data.json` or the OS keyring. The empty-key failure intentionally matches the missing-key behavior (`NotLoggedInError`, exit 1) rather than the pre-move warn + exit 0, per the series' typed-failure convention; the deeper alternative (tightening `isLoggedIn` globally) was deliberately not taken. ## Verification `pnpm --filter @composio/cli test` (204 files, 2262 passed, 1 skipped; includes the two new regression tests), `pnpm --filter @composio/cli run lint:effect` (0 diagnostics), `validate:command-tests` (2 exemptions, unchanged), root `pnpm typecheck`, `pnpm lint` (no warnings in touched files), prettier clean.