-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Changing event rule action type messes up Conditions field #14838
Comments
Btw, the error message (that happens if the event rule with the modified Conditions is saved) is slightly incorrect: Ruleset must be a dictionary, not <class 'django.forms.fields.JSONString'>. A Python dictionary is not necessarily valid JSON (take for example |
This is occurring because the initial data passed as a query parameter when re-rendering the form is interpreted as a string and automatically escaped. The same behavior can be observed by manually passing initial data to the form. For instance, We need some logic in place to detect and load initial data as JSON, rather than treating it as a string. @DanSheps I'm going to take this one if you don't mind as I think we can fix this pretty easily under the field class' |
Deployment Type
Self-hosted
NetBox Version
v3.7.1
Python Version
3.11
Steps to Reproduce
{ "and": [{"attr": "status.value", "value": "deprecated"}]}
Expected Behavior
Conditions field stays as-is
Observed Behavior
Conditions field is rewritten as invalid JSON:
"{ \"and\": [{\"attr\": \"status.value\", \"value\": \"deprecated\"}]}"
The quoting is added with every change of the Action type.
This also happens if editing an existing event rule and changing the Action type.
Workaround
The text was updated successfully, but these errors were encountered: