Browse Source

fix: trim whitespace from group name in filer store operations

Trim leading/trailing whitespace from group.Name before validation
in CreateGroup and UpdateGroup to prevent whitespace-only filenames.
Also merge groups by name during multi-file load to prevent duplicates.
pull/8560/head
Chris Lu 18 hours ago
parent
commit
dfa4a37b96
  1. 6
      weed/credential/filer_etc/filer_etc_group.go

6
weed/credential/filer_etc/filer_etc_group.go

@ -101,6 +101,9 @@ func (store *FilerEtcStore) deleteGroupFile(ctx context.Context, groupName strin
}
func (store *FilerEtcStore) CreateGroup(ctx context.Context, group *iam_pb.Group) error {
if group != nil {
group.Name = strings.TrimSpace(group.Name)
}
if group == nil || group.Name == "" {
return fmt.Errorf("group name is required")
}
@ -162,6 +165,9 @@ func (store *FilerEtcStore) ListGroups(ctx context.Context) ([]string, error) {
}
func (store *FilerEtcStore) UpdateGroup(ctx context.Context, group *iam_pb.Group) error {
if group != nil {
group.Name = strings.TrimSpace(group.Name)
}
if group == nil || group.Name == "" {
return fmt.Errorf("group name is required")
}

Loading…
Cancel
Save