Fix crash when editing rules with hyphenated predefined condition IDs#932
Open
mueller-ma wants to merge 1 commit into
Open
Fix crash when editing rules with hyphenated predefined condition IDs#932mueller-ma wants to merge 1 commit into
mueller-ma wants to merge 1 commit into
Conversation
Predefined condition identifiers created in Checkmk 2.4 or earlier could contain hyphens (e.g. 'cond_host_monitoring-01'). The new rule catalog renderer passed these idents directly as SingleChoiceElement names, which requires valid Python identifiers, causing a ValueError when opening or editing any rule that referenced such a condition. Fix by using SingleChoiceExtended / SingleChoiceElementExtended (internal API) instead of the public SingleChoice / SingleChoiceElement for the predefined conditions list. The Extended variants do not validate names as Python identifiers. Refs: https://forum.checkmk.com/t/unable-to-edit-rules-when-explicit-hostname-contains-hyphens/59918
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for your interest in contributing to Checkmk!
Consider looking into Readme regarding process details.
General information
Predefined condition identifiers created in Checkmk 2.4 or earlier could contain hyphens (e.g. 'cond_host_monitoring-01'). The new rule catalog renderer passed these idents directly as SingleChoiceElement names, which requires valid Python identifiers, causing a ValueError when opening or editing any rule that referenced such a condition.
Fix by using SingleChoiceExtended / SingleChoiceElementExtended (internal API) instead of the public SingleChoice / SingleChoiceElement for the predefined conditions list. The Extended variants do not validate names as Python identifiers.
Bug reports
See https://forum.checkmk.com/t/unable-to-edit-rules-when-explicit-hostname-contains-hyphens/59918
Proposed changes
Same fix than in 9d1fe1a
Disclaimer: AI generated and untested.