From dfa4a37b966c4d7954ec319bd93b0a096932ea7e Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 9 Mar 2026 00:32:02 -0700 Subject: [PATCH] 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. --- weed/credential/filer_etc/filer_etc_group.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/weed/credential/filer_etc/filer_etc_group.go b/weed/credential/filer_etc/filer_etc_group.go index 624a42a5a..22ae6e230 100644 --- a/weed/credential/filer_etc/filer_etc_group.go +++ b/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") }