Files
coder/coderd/database
Jeremy Ruppel 2d65ff14c3 fix(coderd): sort built-in and custom roles for stable list order (#32463)
The role selector on the new user page showed roles in a different order
on every load. `SiteBuiltInRoles()` and `OrganizationRoles()` built
their lists by ranging over the `builtInRoles` map, so `GET
/api/v2/users/roles` and `GET /api/v2/organizations/{org}/members/roles`
returned built-in roles in random order.

Both functions now sort roles by name before returning. The
`CustomRoles` query also had no `ORDER BY`, so custom roles, which are
appended after the built-in ones, now come back ordered by `name,
organization_id`.

`TestListRoles` and `TestReadCustomRoles` now assert the exact order.
Each fails without its fix and passes with it.

Closes CLIENT-1104

---

*Generated by Coder Agents on behalf of @jeremyruppel.*
2026-12-01 09:31:21 -05:00
..
…
…