Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List analyses serializer returning Portfolio does not exist error #995

Closed
sambles opened this issue Mar 12, 2024 · 1 comment · Fixed by #996
Closed

List analyses serializer returning Portfolio does not exist error #995

sambles opened this issue Mar 12, 2024 · 1 comment · Fixed by #996

Comments

@sambles
Copy link
Contributor

sambles commented Mar 12, 2024

Issue Description

Calling /api/v2/analyses/ throws an Internal Server Error (Portfolio matching query does not exist) when calling get_groups from an analysis model.

def get_groups(self):
groups = []
portfolio_groups = self.portfolio.groups.all()
for group in portfolio_groups:
groups.append(group.name)
return groups

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
@sambles
Copy link
Contributor Author

sambles commented Mar 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants