Skip to content

Commit 59a5ef7

Browse files
committed
fix: enhance environment name validation to limit length to 32 characters
1 parent 406a49a commit 59a5ef7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

backend/backend/graphene/mutations/environment.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def mutate(
115115
"You don't have permission to create environments in this organisation"
116116
)
117117

118-
if not re.match(r"^[a-zA-Z0-9\-_]+$", environment_data.name):
118+
if not re.match(r"^[a-zA-Z0-9\-_]{1,32}$", environment_data.name):
119119
raise GraphQLError(
120-
"Environment name is invalid! Environment names can only includes letters, numbers, hyphens and underscores."
120+
"Environment name is invalid! Environment names can only includes letters, numbers, hyphens and underscores, and must be 32 characters or less."
121121
)
122122

123123
if Environment.objects.filter(
@@ -214,9 +214,9 @@ def mutate(cls, root, info, environment_id, name):
214214
"Your Organisation doesn't have access to Custom Environments"
215215
)
216216

217-
if not re.match(r"^[a-zA-Z0-9\-_]+$", name):
217+
if not re.match(r"^[a-zA-Z0-9\-_]{1,32}$", name):
218218
raise GraphQLError(
219-
"Environment name is invalid! Environment names can only includes letters, numbers, hyphens and underscores."
219+
"Environment name is invalid! Environment names can only includes letters, numbers, hyphens and underscores, and must be 32 characters or less."
220220
)
221221

222222
if (

0 commit comments

Comments
 (0)