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

WATO Tags: fix exception when changing an existing tag ID #338

Closed
wants to merge 1 commit into from
Closed

WATO Tags: fix exception when changing an existing tag ID #338

wants to merge 1 commit into from

Conversation

Notausstieg0309
Copy link
Contributor

@Notausstieg0309 Notausstieg0309 commented Mar 12, 2021

When changing the tag id of an already used tag and choose "Fix affected folders, hosts and rules" when saving those changes, the following exception appears:

TypeError (isinstance() arg 2 must be a class, type, or tuple of classes and types)

File "/omd/sites/wsqm/share/check_mk/web/app/index.wsgi", line 101, in _process_request
    self._handle_request()
  File "/omd/sites/wsqm/share/check_mk/web/app/index.wsgi", line 218, in _handle_request
    handler()
  File "/omd/sites/wsqm/lib/python/cmk/gui/pages.py", line 152, in <lambda>
    return lambda: handle_class().handle_page()
  File "/omd/sites/wsqm/lib/python/cmk/gui/pages.py", line 46, in handle_page
    self.page()
  File "/omd/sites/wsqm/lib/python/cmk/gui/pages.py", line 128, in <lambda>
    "page": lambda self: self._wrapped_callable[0]()
  File "/omd/sites/wsqm/lib/python/cmk/gui/wato/__init__.py", line 436, in page_handler
    _wato_page_handler(current_mode, mode_permissions, mode_class)
  File "/omd/sites/wsqm/lib/python/cmk/gui/wato/__init__.py", line 473, in _wato_page_handler
    result = mode.action()
  File "/omd/sites/wsqm/lib/python/cmk/gui/wato/pages/tags.py", line 569, in action
    message = _rename_tags_after_confirmation(operation)
  File "/omd/sites/wsqm/lib/python/cmk/gui/wato/pages/tags.py", line 720, in _rename_tags_after_confirmation
    _change_host_tags_in_folders(operation, mode, watolib.Folder.root_folder())
  File "/omd/sites/wsqm/lib/python/cmk/gui/wato/pages/tags.py", line 839, in _change_host_tags_in_folders
    affected_rulesets += _change_host_tags_in_rules(operation, mode, folder)
  File "/omd/sites/wsqm/lib/python/cmk/gui/wato/pages/tags.py", line 910, in _change_host_tags_in_rules
    affected_rulesets.update(_change_host_tags_in_rule(operation, mode, ruleset, rule))
  File "/omd/sites/wsqm/lib/python/cmk/gui/wato/pages/tags.py", line 974, in _change_host_tags_in_rule
    was_negated = isinstance(dict, current_value) and "$ne" in current_value

The problem is quite trivial, as the call to isinstance() was taken with the wrong parameter order. First, the checked value (current_value) and then after, the data type (dict). So I just switched the values.

With this change, the tag replacements where performed successfully.

@LarsMichelsen
Copy link
Member

Thanks for your contribution! The fix will be merged in some minutes.

@Notausstieg0309 Notausstieg0309 deleted the patch-1 branch March 12, 2021 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants