Skip to content

Commit f813cef

Browse files
committed
fix(teams): Better error message for invalid team slug
1 parent c7e7437 commit f813cef

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/sentry/api/endpoints/organization_teams.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from django.db import IntegrityError, transaction
66
from django.db.models import Q
7+
from django.utils.translation import ugettext_lazy as _
78
from rest_framework import serializers, status
89
from rest_framework.response import Response
910

@@ -46,7 +47,15 @@ def __init__(self):
4647

4748
class TeamSerializer(serializers.Serializer):
4849
name = serializers.CharField(max_length=64, required=False)
49-
slug = serializers.RegexField(r'^[a-z0-9_\-]+$', max_length=50, required=False)
50+
slug = serializers.RegexField(
51+
r'^[a-z0-9_\-]+$',
52+
max_length=50,
53+
required=False,
54+
error_messages={
55+
'invalid': _('Enter a valid slug consisting of lowercase letters, '
56+
'numbers, underscores or hyphens.'),
57+
},
58+
)
5059

5160
def validate(self, attrs):
5261
if not (attrs.get('name') or attrs.get('slug')):
@@ -109,8 +118,8 @@ def post(self, request, organization):
109118
110119
:pparam string organization_slug: the slug of the organization the
111120
team should be created for.
112-
:param string name: the name of the organization.
113-
:param string slug: the optional slug for this organization. If
121+
:param string name: the optional name of the team.
122+
:param string slug: the optional slug for this team. If
114123
not provided it will be auto generated from the
115124
name.
116125
:auth: required

src/sentry/static/sentry/app/components/createTeam/createTeamForm.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class CreateTeamForm extends React.Component {
4444
name="slug"
4545
label={t('Team Slug')}
4646
placeholder={t('e.g. operations, web-frontend, desktop')}
47-
help={t('May contain letters, numbers, dashes and underscores.')}
47+
help={t('May contain lowercase letters, numbers, dashes and underscores.')}
4848
required
4949
flexibleControlStateSize
5050
inline={false}

0 commit comments

Comments
 (0)