-
Notifications
You must be signed in to change notification settings - Fork 955
Fleet UI: Handle long fleet names across the Fleets UI #49216
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
base: main
Are you sure you want to change the base?
Changes from all commits
ca164e2
8a89db6
1e66771
32576e8
26977cd
68d17b8
69e65ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - Fixed long fleet names overflowing the fleets table, fleet detail page header, teams dropdown, and manage enroll secrets modal. Fleet name inputs now cap at 255 characters (matching the database column), and the API and GitOps now return a clear validation error instead of a raw "Data too long" MySQL error when a longer name is submitted. | ||
| - Added 255-character caps to additional user-supplied name and description inputs (API user, custom variable, certificate, label, pack, certificate authority forms) to prevent the same class of overflow bug. | ||
| - Fixed long label names overflowing the Labels card on the host details page. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package service | |
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "log/slog" | ||
| "strings" | ||
| "testing" | ||
|
|
@@ -134,6 +135,23 @@ func TestNewTeamNameValidation(t *testing.T) { | |
| teamName: ptr.String("Engineering"), | ||
| wantName: "Engineering", | ||
| }, | ||
| { | ||
| name: "name at max length is accepted", | ||
| teamName: new(strings.Repeat("a", fleet.MaxTeamNameLength)), | ||
| wantName: strings.Repeat("a", fleet.MaxTeamNameLength), | ||
| }, | ||
| { | ||
| name: "name over max length is rejected", | ||
| teamName: new(strings.Repeat("a", fleet.MaxTeamNameLength+1)), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive, I think — Go 1.26 supports I'm not a strong Go reviewer myself — can someone confirm |
||
| wantErr: fmt.Sprintf("may not exceed %d characters", fleet.MaxTeamNameLength), | ||
| }, | ||
| { | ||
| // Guards against regressing to byte-based length checks, which | ||
| // would reject multibyte names that fit within the character cap. | ||
| name: "multibyte name at max character length is accepted", | ||
| teamName: new(strings.Repeat("日", fleet.MaxTeamNameLength)), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive, I think — Go 1.26 supports I'm not a strong Go reviewer myself — can someone confirm |
||
| wantName: strings.Repeat("日", fleet.MaxTeamNameLength), | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
|
|
@@ -257,6 +275,21 @@ func TestModifyTeamNameValidation(t *testing.T) { | |
| teamName: ptr.String("my team"), | ||
| wantName: "my team", | ||
| }, | ||
| { | ||
| name: "name at max length is accepted", | ||
| teamName: new(strings.Repeat("a", fleet.MaxTeamNameLength)), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive, I think — Go 1.26 supports I'm not a strong Go reviewer myself — can someone confirm |
||
| wantName: strings.Repeat("a", fleet.MaxTeamNameLength), | ||
| }, | ||
| { | ||
| name: "name over max length is rejected", | ||
| teamName: new(strings.Repeat("a", fleet.MaxTeamNameLength+1)), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive, I think — Go 1.26 supports I'm not a strong Go reviewer myself — can someone confirm |
||
| wantErr: fmt.Sprintf("may not exceed %d characters", fleet.MaxTeamNameLength), | ||
| }, | ||
| { | ||
| name: "multibyte name at max character length is accepted", | ||
| teamName: new(strings.Repeat("日", fleet.MaxTeamNameLength)), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. False positive, I think — Go 1.26 supports I'm not a strong Go reviewer myself — can someone confirm |
||
| wantName: strings.Repeat("日", fleet.MaxTeamNameLength), | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
|
|
@@ -367,6 +400,21 @@ func TestApplyTeamSpecsNameValidation(t *testing.T) { | |
| teamName: " Engineering ", | ||
| wantName: "Engineering", | ||
| }, | ||
| { | ||
| name: "name at max length is accepted", | ||
| teamName: strings.Repeat("a", fleet.MaxTeamNameLength), | ||
| wantName: strings.Repeat("a", fleet.MaxTeamNameLength), | ||
| }, | ||
| { | ||
| name: "name over max length is rejected", | ||
| teamName: strings.Repeat("a", fleet.MaxTeamNameLength+1), | ||
| wantErr: fmt.Sprintf("may not exceed %d characters", fleet.MaxTeamNameLength), | ||
| }, | ||
| { | ||
| name: "multibyte name at max character length is accepted", | ||
| teamName: strings.Repeat("日", fleet.MaxTeamNameLength), | ||
| wantName: strings.Repeat("日", fleet.MaxTeamNameLength), | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
|
|
||
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.
False positive, I think — Go 1.26 supports
new(expression), and.claude/rules/fleet-go-backend.mdexplicitly steers us towardnew("value")/new(true)/new(42)overptr.String(...). Tests compile and pass locally (go test -run TestNewTeamNameValidation ./ee/server/service/...).I'm not a strong Go reviewer myself — can someone confirm
new(strings.Repeat(...))(function-call expression, not a literal) is fine per current convention, or should I swap toptr.String(...)for readability?