Skip to content

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

@lunkwill42

Description

@lunkwill42

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

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions