-
Notifications
You must be signed in to change notification settings - Fork 905
refactor: increase group name limit to 255 #15377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
{"", false}, | ||
{"my-group", true}, | ||
{"create", false}, | ||
{"new", false}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this invalid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid route conflicts.
// Avoid conflicts with routes like /templates/new and /groups/create.
if str == "new" || str == "create" {
return xerrors.Errorf("cannot use %q as a name", str)
}
@ethanndickson @code-asher I see you both worked on this group name validation in the past, so I'm just checking if my changes are ok. |
codersdk/name_test.go
Outdated
{randomString(255), true}, | ||
{randomString(256), false}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use testutil.GetRandomName(...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think get random name is limited in length 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, then perhaps namesgenerator.GetRandomName(255)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetRandomName
only checks if the argument is greater than 0, and if it is, appends a random number between 1 and 10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, one last guess: cryptorand.String(...)
codersdk/name_test.go
Outdated
t.Run(testCase.Name, func(t *testing.T) { | ||
t.Parallel() | ||
err := codersdk.GroupNameValid(testCase.Name) | ||
assert.Equal(t, testCase.Valid, err == nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you modify this to contain the error if something bad happens:
assert.Equal(t, testCase.Valid, err == nil, "Test case %s failed: expected valid=%t but got error: %v", testCase.Name, testCase.Valid, err)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once Marcin's feedback is addressed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, the 36 char limit was pretty arbitrary so this makes sense to me.
…crease-group-name-length
Close #15184