Amir Monshi - Note: Could you make sure the analysis name and id is logged when encountered?
Version / Environment information
2.3.0, 2.3.0
Example data / logs
GET /api/v2/analyses/[0m
src.server.oasisapi.portfolios.models.Portfolio.DoesNotExist: Portfolio matching query does not exist.
raise self.model.DoesNotExist(
File "/home/server/.local/lib/python3.10/site-packages/django/db/models/query.py", line 435, in get
return qs.get(self.field.get_reverse_related_filter(instance))
File "/home/server/.local/lib/python3.10/site-packages/django/db/models/fields/related_descriptors.py", line 154, in get_object
rel_obj = self.get_object(instance)
File "/home/server/.local/lib/python3.10/site-packages/django/db/models/fields/related_descriptors.py", line 187, in __get__
portfolio_groups = self.portfolio.groups.all()
File "/var/www/oasis/src/server/oasisapi/analyses/models.py", line 311, in get_groups
return instance.get_groups()
File "/var/www/oasis/src/server/oasisapi/analyses/v2_api/serializers.py", line 162, in get_groups
return method(value)
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/fields.py", line 1838, in to_representation
ret[field.field_name] = field.to_representation(attribute)
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/serializers.py", line 522, in to_representation
self.child.to_representation(item) for item in iterable
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/serializers.py", line 687, in <listcomp>
return [
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/serializers.py", line 686, in to_representation
self._data = self.to_representation(self.instance)
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/serializers.py", line 253, in data
ret = super().data
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/serializers.py", line 768, in data
return Response(serializer.data)
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/mixins.py", line 46, in list
return bound_method(*args, **kwargs)
File "/home/server/.local/lib/python3.10/site-packages/django/utils/decorators.py", line 43, in _wrapper
response = handler(request, *args, **kwargs)
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
raise exc
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
self.raise_uncaught_exception(exc)
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
response = self.handle_exception(exc)
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
return self.dispatch(request, *args, **kwargs)
File "/home/server/.local/lib/python3.10/site-packages/rest_framework/viewsets.py", line 125, in view
return view_func(*args, **kwargs)
File "/home/server/.local/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/server/.local/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = get_response(request)
File "/home/server/.local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
Reported: So it seems it happens when two analysis are created back to back pointing to the same portfolio and the list is called immediately after. Not that none of these analyses are started at this point.
Issue Description
Calling
/api/v2/analyses/
throws an Internal Server Error (Portfolio matching query does not exist) when callingget_groups
from an analysis model.https://github.com/OasisLMF/OasisPlatform/blob/588280191782af3813f6ae8ce3feb9063c2c1fd9/src/server/oasisapi/analyses/models.py#L309-L314
Version / Environment information
2.3.0
,2.3.0
Example data / logs