Skip to content
Snippets Groups Projects
Commit 279681b1 authored by Sergios Aftsidis's avatar Sergios Aftsidis
Browse files

Fix issue with `request.user` in Celery task

When the user was not a "superuser", `request.user` was being
passed in the route object sent as a Celery job. This led to
an error (only reproducable in one of our instances, don't know
the exact conditions since all packets & versions seemed to be
identical):

    EncodeError: dictionary changed size during iteration

Fix:

* Use the `User` object retrieved from the ORM instead

Also, store the user even if the route is created from an admin.
parent 80007541
No related branches found
No related tags found
No related merge requests found
......@@ -296,8 +296,7 @@ def add_route(request):
form = RouteForm(request_data)
if form.is_valid():
route = form.save(commit=False)
if not request.user.is_superuser:
route.applier = request.user
route.applier = User.objects.get(username=request.user.username)
route.status = "PENDING"
route.response = "Applying"
route.source = IPNetwork('%s/%s' % (IPNetwork(route.source).network.compressed, IPNetwork(route.source).prefixlen)).compressed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment