Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: add missing env tier guard (#16835)

ecmadao8fdccb5d31b1
diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.go
index 1aa27ddbb3..f34fd5dadd 100644
--- a/backend/api/v1/setting_service.go
+++ b/backend/api/v1/setting_service.go
@@ -514,7 +514,7 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *connect.Req
}
storeSettingValue = string(bytes)
case storepb.SettingName_ENVIRONMENT:
- if serr := validateEnvironments(request.Msg.Setting.Value.GetEnvironmentSetting().GetEnvironments()); serr != nil {
+ if serr := s.validateEnvironments(request.Msg.Setting.Value.GetEnvironmentSetting().GetEnvironments()); serr != nil {
return nil, serr
}
@@ -1140,7 +1140,7 @@ func validateDomains(domains []string) error {
return nil
}
-func validateEnvironments(envs []*v1pb.EnvironmentSetting_Environment) error {
+func (s *SettingService) validateEnvironments(envs []*v1pb.EnvironmentSetting_Environment) error {
used := map[string]bool{}
for _, env := range envs {
if env.Title == "" {
@@ -1152,6 +1152,11 @@ func validateEnvironments(envs []*v1pb.EnvironmentSetting_Environment) error {
if used[env.Id] {
return connect.NewError(connect.CodeInvalidArgument, errors.Errorf("duplicate environment ID %v", env.Id))
}
+ if v, ok := env.Tags["protected"]; ok && v == "protected" {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanFeature_FEATURE_ENVIRONMENT_TIERS); err != nil {
+ return connect.NewError(connect.CodePermissionDenied, err)
+ }
+ }
used[env.Id] = true
}
return nil