Skip to content

Webhook conditions process tags incorrectly #9797

@beginin

Description

@beginin

NetBox version

v3.2.6

Python version

3.9

Steps to Reproduce

  1. Create webhook use doc https://docs.netbox.dev/en/stable/reference/conditions/ and https://docs.netbox.dev/en/stable/additional-features/webhooks/
    {
    "id": 2,
    "url": "https://{{hide}}/api/extras/webhooks/2/",
    "display": "KVM Configuration",
    "content_types": [
    "dcim.device"
    ],
    "name": "KVM Configuration",
    "type_create": true,
    "type_update": true,
    "type_delete": false,
    "payload_url": "https://{{hide}}",
    "enabled": true,
    "http_method": "POST",
    "http_content_type": "application/json",
    "additional_headers": "",
    "body_template": "{"token": "secret",\r\n"ref": "main"}",
    "secret": "",
    "conditions": {
    "and": [
    {
    "op": "contains",
    "attr": "tags",
    "value": "kvm_configuration_needed"
    }
    ]
    },
    "ssl_verification": false,
    "ca_file_path": null,
    "created": "2022-06-14T06:44:34.198779Z",
    "last_updated": "2022-07-20T10:52:47.492639Z"
    }

Expected Behavior

  1. When I updates com.device I expect get request https://{{hide}}

I try to debug and found this code witch work incorrectly
https://github.com/netbox-community/netbox/blob/v3.2.6/netbox/extras/conditions.py#L106

I sniffed vars
self.value is 'kvm_configuration_needed'
value is [OrderedDict([('id', 75), ('url', '/api/extras/tags/75/'), ('display', 'kvm_configuration_needed'), ('name', 'kvm_configuration_needed'), ('slug', 'kvm_configuration_needed'), ('color', 'ff9800')]), OrderedDict([('id', 77), ('url', '/api/extras/tags/77/'), ('display', 'kvm_failed'), ('name', 'kvm_failed'), ('slug', 'kvm_failed'), ('color', 'f44336')])]
value is list of dictionaries

condition self.value in value will be always false for list of dictionaries.

Observed Behavior

Get request https://{{hide}} is not happening

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugA confirmed report of unexpected behavior in the application

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions