Rate Limiting endpoint fails when unauthenticated
Steps to reproduce
- Open https://docs.funkwhale.audio/swagger/
- Configure the remote server
- Attempt to execute /api/v1/rate-limit/
What happens?
Swagger reports a 500 error. In the api logs the server attempts to convert the source IP address to an ident field which is int() type.
2023-11-10 17:29:53,281 django.request ERROR Internal Server Error: /api/v1/rate-limit/
Traceback (most recent call last):
File "/venv/lib/python3.10/site-packages/asgiref/sync.py", line 534, in thread_handler
raise exc_info[1]
File "/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 38, in inner
response = await get_response(request)
File "/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 233, in _get_response_async
response = await wrapped_callback(request, *callback_args, **callback_kwargs)
File "/venv/lib/python3.10/site-packages/asgiref/sync.py", line 479, in __call__
ret: _R = await loop.run_in_executor(
File "/venv/lib/python3.10/site-packages/asgiref/current_thread_executor.py", line 40, in run
result = self.fn(*self.args, **self.kwargs)
File "/venv/lib/python3.10/site-packages/asgiref/sync.py", line 538, in thread_handler
return func(*args, **kwargs)
File "/usr/lib/python3.10/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/venv/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/venv/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/venv/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/venv/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/venv/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/app/funkwhale_api/common/views.py", line 151, in get
return response.Response(serializers.RateLimitSerializer(data).data, status=200)
File "/venv/lib/python3.10/site-packages/rest_framework/serializers.py", line 555, in data
ret = super().data
File "/venv/lib/python3.10/site-packages/rest_framework/serializers.py", line 253, in data
self._data = self.to_representation(self.instance)
File "/venv/lib/python3.10/site-packages/rest_framework/serializers.py", line 522, in to_representation
ret[field.field_name] = field.to_representation(attribute)
File "/venv/lib/python3.10/site-packages/rest_framework/serializers.py", line 522, in to_representation
ret[field.field_name] = field.to_representation(attribute)
File "/venv/lib/python3.10/site-packages/rest_framework/fields.py", line 915, in to_representation
return int(value)
ValueError: invalid literal for int() with base 10: '192.168.225.90'
What is expected?
The rate-limit api should return the unauthenticated rate-limit values.
Context
Funkwhale version(s) affected: 1.3.3