diff --git a/server/public/model/custom_profile_attributes.go b/server/public/model/custom_profile_attributes.go index 1a2a65dfe3d..1987b2f47d6 100644 --- a/server/public/model/custom_profile_attributes.go +++ b/server/public/model/custom_profile_attributes.go @@ -66,8 +66,11 @@ func (c CustomProfileAttributesSelectOption) IsValid() error { type CustomProfileAttributesSelectOptions []CustomProfileAttributesSelectOption func (c CustomProfileAttributesSelectOptions) IsValid() error { - seenNames := make(map[string]struct{}) + if len(c) == 0 { + return errors.New("options list cannot be empty") + } + seenNames := make(map[string]struct{}) for _, option := range c { if err := option.IsValid(); err != nil { return err diff --git a/server/public/model/custom_profile_attributes_test.go b/server/public/model/custom_profile_attributes_test.go index f6084a3683b..8c1b4548619 100644 --- a/server/public/model/custom_profile_attributes_test.go +++ b/server/public/model/custom_profile_attributes_test.go @@ -101,7 +101,7 @@ func TestCustomProfileAttributesSelectOptionsIsValid(t *testing.T) { { name: "empty options", options: CustomProfileAttributesSelectOptions{}, - wantErr: "", + wantErr: "options list cannot be empty", }, { name: "valid options",