Skip to content

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

fix: no need to limit the environment title (#16076)

ecmadao2e9071088ebc
diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.go
index 05ba417e88..9ae14473ad 100644
--- a/backend/api/v1/setting_service.go
+++ b/backend/api/v1/setting_service.go
@@ -1343,8 +1343,8 @@ func validateDomains(domains []string) error {
func validateEnvironments(envs []*v1pb.EnvironmentSetting_Environment) *status.Status {
used := map[string]bool{}
for _, env := range envs {
- if err := base.IsValidEnvironmentName(env.Title); err != nil {
- return status.Newf(codes.InvalidArgument, "invalid environment title, error %v", err.Error())
+ if env.Title == "" {
+ return status.Newf(codes.InvalidArgument, "environment title cannot be empty")
}
if !isValidResourceID(env.Id) {
return status.Newf(codes.InvalidArgument, "invalid environment ID %v", env.Id)
diff --git a/backend/base/environment.go b/backend/base/environment.go
deleted file mode 100644
index 4e2ff83a4b..0000000000
--- a/backend/base/environment.go
+++ /dev/null
@@ -1,24 +0,0 @@
-package base
-
-import (
- "regexp"
-
- "github.com/pkg/errors"
-)
-
-// placeholderRegexp is the regexp for placeholder.
-// Refer to https://stackoverflow.com/a/6222235/19075342, but we support '.' for now.
-var placeholderRegexp = regexp.MustCompile(`[^\\/?%*:|"<>]+`)
-var alphaNumeric = regexp.MustCompile(`^[a-zA-Z0-9]*$`)
-
-// IsValidEnvironmentName checks if the environment name is valid.
-func IsValidEnvironmentName(environmentName string) error {
- if !placeholderRegexp.MatchString(environmentName) {
- return errors.Errorf("environment title %q cannot contain placeholder characters (\\, /, ?, %%, *, :, |, \", <, >)", environmentName)
- }
- if !alphaNumeric.MatchString(environmentName) {
- return errors.Errorf("environment title %q can only contain alphabet numeric characters (a-z, A-Z, 0-9)", environmentName)
- }
-
- return nil
-}