fix(cli): allow site admins to use coder create --org for any organization#21528
Merged
ethanndickson merged 1 commit intomainfrom Feb 16, 2026
Merged
fix(cli): allow site admins to use coder create --org for any organization#21528ethanndickson merged 1 commit intomainfrom
coder create --org for any organization#21528ethanndickson merged 1 commit intomainfrom
Conversation
coder create --org for any organization
Site-wide admins (e.g., Owners) can now use the --org flag to select organizations they are not members of. Previously, OrganizationContext.Selected() only checked the user's membership list, causing 'organization not found' errors even when the user had RBAC permission to access the org. The fix adds a fallback that fetches the org directly via the API when not found in the membership list. This works because the API endpoint applies RBAC filtering, allowing Owners to read any org. This fixes all 29+ CLI commands that use OrganizationContext.Selected(), including: - coder create --org <any-org> - coder templates push --org <any-org> - coder organizations members add --org <any-org>
4f299d8 to
294a0f1
Compare
Member
Author
|
I ran into this working on mux, figured I'd fix it. |
Contributor
|
Code LGTM. |
geokat
reviewed
Feb 6, 2026
Emyrk
approved these changes
Feb 6, 2026
Member
Emyrk
left a comment
There was a problem hiding this comment.
LGTM. This does mean a user might be able to see another org, but not make a workspace or something. As long as these orgs are not discoverable, and only addressable by knowing the name, this is fine
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
Site-wide admins (e.g., Owners) could not use
coder create --org <org>to create workspaces in organizations they are not members of. The error was:This was inconsistent with the web UI, where Owners can create workspaces in any organization.
Root Cause
The CLI's
OrganizationContext.Selected()function only checked the user's membership list, ignoring site-wide RBAC permissions that grant Owners access to all organizations.Solution
Added a fallback in
OrganizationContext.Selected()that fetches the org directly via the API when not found in the membership list. This works because the API endpoint applies RBAC filtering, allowing Owners to read any org.Impact
This fixes
coder create --organd all other CLI commands that useOrganizationContext.Selected()(29+ commands), including:coder templates push --org <any-org>coder organizations members add --org <any-org>coder provisioner list --org <any-org>Testing
Added
TestEnterpriseCreate/OwnerCanCreateInNonMemberOrgwhich:--orgThis PR was generated by mux but reviewed by a human.