fix: allow org switch by ID when org not in paginated list by jlaneve · Pull Request #2000 · astronomer/astro-cli

@jlaneve @claude

When a user has access to more than 100 organizations, the target org
may not appear in the paginated list returned by ListOrganizations.
This change adds a fallback that attempts to fetch the organization
directly by ID if it's not found in the list.

- Add explicit limit of 100 to ListOrganizations
- Add new GetOrganization function to fetch org by ID
- Add fallback in Switch to try GetOrganization when org not in list

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

jeremybeard

@jlaneve @claude

Replace the blind GetOrganization fallback with a three-way dispatch:
- CUID input → direct GetOrganization (1 API call)
- Name input → paginate through all ListOrganizations pages
- Empty input → interactive selection (unchanged)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The mocks were using exact param matching with empty
ListOrganizationsParams{}, but ListOrganizations always passes
Limit=100. This was a pre-existing issue. Switch to mock.Anything.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

jeremybeard

@jlaneve jlaneve deleted the fix/org-switch-pagination-fallback branch

March 2, 2026 19:09

This was referenced

Mar 2, 2026