From cea1f4a3e8e05c69d1aa9dbc56c85eed1a3addd8 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 9 Mar 2026 00:32:09 -0700 Subject: [PATCH] fix: add nil/empty group validation in gRPC store Guard CreateGroup and UpdateGroup against nil group or empty name to prevent panics and invalid persistence. --- weed/credential/grpc/grpc_group.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/weed/credential/grpc/grpc_group.go b/weed/credential/grpc/grpc_group.go index 394dc13ca..be0c155db 100644 --- a/weed/credential/grpc/grpc_group.go +++ b/weed/credential/grpc/grpc_group.go @@ -2,6 +2,7 @@ package grpc import ( "context" + "fmt" "github.com/seaweedfs/seaweedfs/weed/credential" "github.com/seaweedfs/seaweedfs/weed/pb/iam_pb" @@ -13,6 +14,9 @@ import ( // A future improvement would add dedicated gRPC RPCs for atomic group operations. func (store *IamGrpcStore) CreateGroup(ctx context.Context, group *iam_pb.Group) error { + if group == nil || group.Name == "" { + return fmt.Errorf("group name is required") + } config, err := store.LoadConfiguration(ctx) if err != nil { return err @@ -66,6 +70,9 @@ func (store *IamGrpcStore) ListGroups(ctx context.Context) ([]string, error) { } func (store *IamGrpcStore) UpdateGroup(ctx context.Context, group *iam_pb.Group) error { + if group == nil || group.Name == "" { + return fmt.Errorf("group name is required") + } config, err := store.LoadConfiguration(ctx) if err != nil { return err