refactor: increase group name limit to 255 (#15377)

Close https://github.com/coder/coder/issues/15184
This commit is contained in:
Bruno Quaresma
2024-11-06 14:39:50 -03:00
committed by GitHub
parent 17363098e2
commit 7f510051fb
2 changed files with 46 additions and 3 deletions
+7 -3
View File
@@ -1,6 +1,7 @@
package codersdk
import (
"fmt"
"regexp"
"strings"
@@ -98,9 +99,12 @@ func UserRealNameValid(str string) error {
// GroupNameValid returns whether the input string is a valid group name.
func GroupNameValid(str string) error {
// 36 is to support using UUIDs as the group name.
if len(str) > 36 {
return xerrors.New("must be <= 36 characters")
// We want to support longer names for groups to allow users to sync their
// group names with their identity providers without manual mapping. Related
// to: https://github.com/coder/coder/issues/15184
limit := 255
if len(str) > limit {
return xerrors.New(fmt.Sprintf("must be <= %d characters", limit))
}
// Avoid conflicts with routes like /groups/new and /groups/create.
if str == "new" || str == "create" {