From 59626e22c3056b2e0c519b95b064650874c7ac26 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 8 Mar 2026 23:50:15 -0700 Subject: [PATCH] fix: merge groups by name instead of blind append during filer load Match the identity loader's merge behavior: find existing group by name and replace, only append when no match exists. Prevents duplicates when legacy and multi-file configs overlap. --- weed/credential/filer_etc/filer_etc_group.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/weed/credential/filer_etc/filer_etc_group.go b/weed/credential/filer_etc/filer_etc_group.go index 250930bc8..624a42a5a 100644 --- a/weed/credential/filer_etc/filer_etc_group.go +++ b/weed/credential/filer_etc/filer_etc_group.go @@ -47,7 +47,18 @@ func (store *FilerEtcStore) loadGroupsFromMultiFile(ctx context.Context, s3cfg * if err := json.Unmarshal(content, g); err != nil { return fmt.Errorf("failed to unmarshal group %s: %w", entry.Name, err) } - s3cfg.Groups = append(s3cfg.Groups, g) + // Merge: overwrite existing group with same name or append + found := false + for i, existing := range s3cfg.Groups { + if existing.Name == g.Name { + s3cfg.Groups[i] = g + found = true + break + } + } + if !found { + s3cfg.Groups = append(s3cfg.Groups, g) + } } } return nil