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

[BUG] Changing filter order in an Alert profiles filter group crashes with a RuntimeError #2979

Closed
lunkwill42 opened this issue Sep 17, 2024 · 1 comment · Fixed by #2980
Closed
Assignees

Comments

@lunkwill42
Copy link
Member

lunkwill42 commented Sep 17, 2024

Describe the bug

When editing a "filter group" in the Alert Profiles web tool, if a user clicks the "Move up" or "Move down" button for any of multiple filters in a group, the UI crashes with a Python RuntimeError

Expected behavior

The filter position should be moved within the filter group, no crash.

Tracebacks

Environment:


Request Method: POST
Request URL: http://localhost/alertprofiles/filter-groups/remove-filter/

Django Version: 3.2.25
Python Version: 3.9.2
Installed Applications:
('nav.models',
 'nav.web',
 'nav.django',
 'django.contrib.staticfiles',
 'django.contrib.sessions',
 'django.contrib.humanize',
 'django_filters',
 'crispy_forms',
 'crispy_forms_foundation',
 'rest_framework',
 'nav.auditlog',
 'nav.web.macwatch',
 'nav.web.geomap',
 'nav.portadmin.napalm',
 'nav.web.portadmin',
 'django.contrib.postgres')
Installed Middleware:
('django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'nav.web.auth.middleware.AuthenticationMiddleware',
 'nav.web.auth.middleware.AuthorizationMiddleware',
 'nav.django.legacy.LegacyCleanupMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')



Traceback (most recent call last):
  File "/opt/venvs/nav/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/venvs/nav/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/source/python/nav/web/alertprofiles/decorators.py", line 47, in _handler
    return func(request, *args, **kwargs)
  File "/source/python/nav/web/alertprofiles/views.py", line 2053, in filter_group_remove_or_move_filter
    for name in post:

Exception Type: RuntimeError at /alertprofiles/filter-groups/remove-filter/
Exception Value: dictionary keys changed during iteration

Environment (please complete the following information):

  • OS on the NAV server: Any
  • NAV version installed: 5.10.2
@lunkwill42
Copy link
Member Author

This was reported by RENU. Not sure why this silly bug wasn't reported by anyone before, but it seems to be something that got lost a few years back when NAV moved from Python 2 to 3: Dictionary elements cannot be deleted while iterating over its elements under Python 3.

@lunkwill42 lunkwill42 self-assigned this Sep 17, 2024
@lunkwill42 lunkwill42 modified the milestone: 5.10.0 Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant