fix: allow org switch by ID when org not in paginated list#2000
Open
fix: allow org switch by ID when org not in paginated list#2000
Conversation
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
reviewed
Jan 28, 2026
| targetOrg = &or[i] | ||
| } | ||
| } | ||
| // If not found in list, try to get org by ID directly |
Contributor
There was a problem hiding this comment.
It's unfortunate that we have this ambiguous value that could be a name or an ID. I'd prefer if we could deal with this more systematically than a hail mary get org call if the first page of list orgs doesn't produce it. Can we look at the value and if it is a CUID then we do a get org call, otherwise we paginate through list orgs responses until we find it? Then we avoid unnecessary lookups, and if we don't find it we know it is really not there instead of maybe being on another page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ListOrganizationsGetOrganizationfunction to fetch an org directly by IDSwitchto try fetching by ID when org isn't found in the listTest plan
go test ./cloud/organization/...)🤖 Generated with Claude Code