fix(coderd/database): match group name case-insensitively in search - #27894
Merged
david-fraley merged 1 commit intoAug 5, 2026
Merged
Conversation
shared_with_group:<org>/<name> workspace searches failed whenever the group name contained uppercase letters. The search parser lowercases the whole query before resolving the group, but GetGroupByOrgAndName matched the name with an exact-case comparison, so the lookup missed the row and returned a misleading not-found/unauthorized error. Make GetGroupByOrgAndName case-insensitive with LOWER(name) = LOWER(@name), matching GetOrganizationByName and workspace name lookups. Guard the group rename conflict check so a case-only rename does not match itself. Fixes PRODUCT-518.
Emyrk
approved these changes
Aug 5, 2026
Emyrk
left a comment
Member
There was a problem hiding this comment.
LGTM.
We should block naming multiple groups with the same letters of different casing anyway. If there is not already a constraint on the db for that
david-fraley
deleted the
dfraley/product-518-group-search-case-insensitive
branch
August 5, 2026 19:21
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
coder list --search shared_with_group:<org>/<name>fails whenever the group's name contains uppercase letters.The workspace search parser lowercases the entire query string before the value is resolved, but
GetGroupByOrgAndNamematched the name with an exact-case comparison (name = $2). The lowercased value therefore never matched a mixed-case group, and the API returned a misleading error implying the group does not exist or the caller is unauthorized. The siblingGetOrganizationByNamealready usesLOWER("name") = LOWER(@name), so the org half of the reference worked case-insensitively while the group half did not. Looking up a group by UUID was unaffected.Fixes PRODUCT-518.
Changes
coderd/database/queries/groups.sql:GetGroupByOrgAndNamenow matches the name case-insensitively (LOWER("name") = LOWER(@name)), consistent with organization and workspace name lookups. Regeneratedqueries.sql.govia sqlc.enterprise/coderd/groups.go: guard the group-rename conflict check so it excludes the group being renamed. Because the lookup is now case-insensitive, a case-only rename (e.g.supportshare->SupportShare) would otherwise match itself and be falsely rejected.TestSearchWorkspace/SharedWithGroupInOrgMixedCaseandTestPatchGroup/RenameCasingOnlyOK.This is a backend/CLI behavior fix with no UI changes. Test output is included below as evidence.
Scope notes / decision log
--shared-with-me/--shared-with-groupCLI ergonomics. Those are separate concerns and are intentionally left out of this bug fix to keep it minimal and reviewable.groupstable has a case-sensitive unique constraintUNIQUE (name, organization_id), so two groups differing only by case can technically coexist; in that rare case the case-insensitive lookup returns one arbitrarily (LIMIT 1). This matches existing organization lookup behavior. Enforcing case-insensitive uniqueness on group creation would require a schema/migration change and is out of scope.ExtractGroupByNameParam(group-by-name URL resolution) case-insensitive, which is consistent with organization URL resolution.This PR was generated by Coder Agents on behalf of @david-fraley.