Skip to content

feat(cli): List organizations across all stored accounts - #1537

Draft
sentry-junior[bot] wants to merge 1 commit into
feat/cli-account-routingfrom
feat/cli-org-list-all-accounts
Draft

sentry-junior[bot] wants to merge 1 commit into
feat/cli-account-routingfrom
feat/cli-org-list-all-accounts

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Stacked on #1528. Follow-up to BYK's question on #1528 about having org list show organizations from every stored account.

When more than one account is stored, sentry org list now lists the organizations of every logged-in account together. Each account is queried concurrently, using its own credentials on its own server, and the stored active account doesn't change. This is done by the new withStoredAccount() in db/auth.ts. It runs the fetch under a copy of the invocation env (withEnv) that has its own account scope, its own credential memo, and SENTRY_URL pinned to that account's host. That means token refreshes or invalidation during the fetch only touch that account, and a token is never sent to another server.

Behavior

  • Human output adds an ACCOUNT column (e.g. jane@acme.com on sentry.acme.com). JSON entries get an account object with id, host, email, username and label.
  • If several accounts on the same server can see an org, it's listed once: under the active account if it's one of them, otherwise under the most recently used one. The same slug on different servers is listed once per server.
  • If one account's request fails (auth or API error), that account is skipped with a warning. The command only fails if every account fails.
  • An explicitly set server (SENTRY_HOST/SENTRY_URL, .sentryclirc) limits the list to accounts on that server, using the same rule as selectAccountForOrg. The new --account <who> flag limits it to one account and uses the shared account selector. A logged-out account gives an AuthError that names the sentry auth login <email> command to run.
  • With a single stored account, or a forced env token (SENTRY_FORCE_ENV_TOKEN), the output is the same as before (no account column or field).
  • Each account's org list also goes into the per-account cache, so later org-scoped commands pick the right account automatically.

Tests
test/commands/org/list.test.ts runs against a real test DB, with a fetch mock that answers per server and per token. It covers per-account token/server routing, the active account staying unchanged, dedupe, skip-on-failure, all-accounts-fail, the explicit-server filter, logged-out accounts, --limit on the merged list, the ACCOUNT column, --account, and later org routing using the newly cached lists. 9 of its 15 tests fail without the source change.

Docs: updated the org and auth fragments and regenerated the org skill reference.

via byk.

--

View Junior Session [Sentry]

With several stored accounts, `sentry org list` now lists the
organizations of every logged-in account together. Each account is
queried concurrently with its own credentials on its own server
(`withStoredAccount`, an isolated env copy with its own account scope),
so tokens never cross servers and the stored active account is
unchanged. Human output adds an ACCOUNT column and JSON entries carry an
`account` object.

- An org reachable from several accounts on the same server is listed
  once, under the active account if it is one of them, else the most
  recently used.
- An account whose request fails is skipped with a warning; the command
  only fails when every account does.
- An explicit server (SENTRY_HOST/SENTRY_URL, .sentryclirc) limits the
  list to accounts on it; `--account <who>` limits it to one account.
- Forced env tokens and single-account setups keep the previous output.

Listing also caches each account's org list, which feeds automatic
account selection for org-scoped commands.

Co-Authored-By: Burak Yigit Kaya <burak.kaya@sentry.io>
@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Oct 17, 2026 6:35am UTC

Request Review

This branch was previously deployed

1 inactive deployment
Preview — 48694c3a Deployed Oct 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants