Error when creating singular Condition for webhook #5959

Closed
opened 2025-12-29 19:34:56 +01:00 by adam · 1 comment
Owner

Originally created by @kkthxbye-code on GitHub (Jan 18, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v.3.1.5

Python version

3.9

Steps to Reproduce

  1. Click on Other -> Webhooks
  2. Add new webhook
  3. Enter the following data: name = test, content types = DCIM > Device, URL: http://127.0.0.1/
  4. Enter the following condition copied from the documentation:
{
  "attr": "name",
  "value": "foo"
}
  1. Save

Expected Behavior

Webhook saves

Observed Behavior

The following error: Ruleset must have exactly one logical operator (found 2)

The following works:

{
    "and": [
        {
            "attr": "name",
            "value": "foo"
        }
    ]
}

Now looking at the code, I'm not sure if this is a bug or I'm just misunderstanding the documentation. To me the documentation implies that singular conditions are allowed at the root level, and only at the bottom of the page are Condition Sets documented.

If I'm just misunderstanding, is the correct way just to wrap singular conditions in the "and" operator?

Condition documentation: https://netbox.readthedocs.io/en/stable/reference/conditions/

Conditional webhooks documentation: https://netbox.readthedocs.io/en/stable/additional-features/webhooks/#conditional-webhooks

Originally created by @kkthxbye-code on GitHub (Jan 18, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v.3.1.5 ### Python version 3.9 ### Steps to Reproduce 1. Click on Other -> Webhooks 2. Add new webhook 3. Enter the following data: name = test, content types = DCIM > Device, URL: http://127.0.0.1/ 4. Enter the following condition copied from the documentation: ``` { "attr": "name", "value": "foo" } ``` 5. Save ### Expected Behavior Webhook saves ### Observed Behavior The following error: Ruleset must have exactly one logical operator (found 2) The following works: ``` { "and": [ { "attr": "name", "value": "foo" } ] } ``` Now looking at the code, I'm not sure if this is a bug or I'm just misunderstanding the documentation. To me the documentation implies that singular conditions are allowed at the root level, and only at the bottom of the page are Condition Sets documented. If I'm just misunderstanding, is the correct way just to wrap singular conditions in the "and" operator? Condition documentation: https://netbox.readthedocs.io/en/stable/reference/conditions/ Conditional webhooks documentation: https://netbox.readthedocs.io/en/stable/additional-features/webhooks/#conditional-webhooks
adam added the status: acceptedtype: documentation labels 2025-12-29 19:34:56 +01:00
adam closed this issue 2025-12-29 19:34:56 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 18, 2022):

IIRC the original intent was to support the simplified expression where only a single AND clause is present, however the implementation to accommodate it proved too unwieldy and was scrapped. The example in the webhook documentation did not get updated to reflect this change.

@jeremystretch commented on GitHub (Jan 18, 2022): IIRC the original intent was to support the simplified expression where only a single AND clause is present, however the implementation to accommodate it proved too unwieldy and was scrapped. The example in the webhook documentation did not get updated to reflect this change.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5959