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

Crash in ZoneStatusRetrieveAjaxView views from getlist() #1752

Closed
Tracked by #1638
mikkonie opened this issue Aug 17, 2023 · 2 comments · Fixed by #1754
Closed
Tracked by #1638

Crash in ZoneStatusRetrieveAjaxView views from getlist() #1752

mikkonie opened this issue Aug 17, 2023 · 2 comments · Fixed by #1754
Assignees
Labels
app: landingzones Issue in the landingzones app bug Something isn't working high priority A decidedly high priority issue
Milestone

Comments

@mikkonie
Copy link
Contributor

mikkonie commented Aug 17, 2023

In staging we observed a crash in ZoneStatusRetrieveAjaxView, dump below in comments.

Looks like we're trying to use getlist() on a dict, which is generally not a good idea :)

How to Reproduce: Navigate to ProjectZonesView in a project with no landing zones available.

Spec

  • Fix the landingzones JQuery to not call for the Ajax view if no zones are in the UI
  • Fix the Ajax view to gracefully handle not receiving any zones in its call
    • Just in case it does get called
    • Just return an empty status_dict and a 200
  • Add an ajax view to test for the view handling an "empty" request
@mikkonie mikkonie added bug Something isn't working app: landingzones Issue in the landingzones app labels Aug 17, 2023
@mikkonie mikkonie added this to the v0.14.0 milestone Aug 17, 2023
@mikkonie
Copy link
Contributor Author

Dump (UUID is from an imaginary project on our staging server so no secret info here):

Internal Server Error: /landingzones/ajax/status/retrieve/874ca631-05c1-4232-8491-9b9d0fbfd2bc

AttributeError at /landingzones/ajax/status/retrieve/874ca631-05c1-4232-8491-9b9d0fbfd2bc
'dict' object has no attribute 'getlist'

(...)

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/src/app/landingzones/views_ajax.py", line 25, in post
    zone_uuids = request.data.getlist('zone_uuids[]')

@mikkonie
Copy link
Contributor Author

Fixed by @gromdimon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app: landingzones Issue in the landingzones app bug Something isn't working high priority A decidedly high priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants