Add a validation to the Service Name Format
Feature Request/Bug
We should add a validator to the Service Name Formatb field
Currently a bad format string causes the discord service to break with a not all that helpful error.
Traceback (most recent call last):
File "/opt/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 56, in inner
response = get_response(request)
File "/opt/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/venv/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/opt/venv/lib/python3.9/site-packages/allianceauth/authentication/decorators.py", line 47, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/opt/venv/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/opt/venv/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/opt/venv/lib/python3.9/site-packages/allianceauth/services/modules/discord/views.py", line 84, in discord_callback
if DiscordUser.objects.add_user(
File "/opt/venv/lib/python3.9/site-packages/allianceauth/services/modules/discord/managers.py", line 62, in add_user
nickname = user_formatted_nick(user) if DISCORD_SYNC_NAMES else None
File "/opt/venv/lib/python3.9/site-packages/allianceauth/services/modules/discord/core.py", line 89, in user_formatted_nick
return NameFormatter(DiscordService(), user).format_name()
File "/opt/venv/lib/python3.9/site-packages/allianceauth/services/hooks.py", line 205, in format_name
return Formatter().vformat(self.string_formatter, args=[], kwargs=format_data).strip()
File "/usr/local/lib/python3.9/string.py", line 165, in vformat
result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
File "/usr/local/lib/python3.9/string.py", line 205, in _vformat
obj, arg_used = self.get_field(field_name, args, kwargs)
File "/usr/local/lib/python3.9/string.py", line 270, in get_field
obj = self.get_value(first, args, kwargs)
File "/usr/local/lib/python3.9/string.py", line 227, in get_value
return kwargs[key]
Exception Type: KeyError at /discord/callback/
Exception Value: ''