Triggering a webhook over an eventrule will cause NetBoxFakeRequest
NetBox Edition
NetBox Community
NetBox Version
v4.7.0
Python Version
3.14
Steps to Reproduce
- I´ve created an eventrule for the Object Type IPAM | IP address. The Eventrule is for Event Types created, updated and deleted. Moreover this rule has an condition which only triggeres like this:
{ "and": [ { "or": [ { "attr": "address", "op": "contains", "value": "XXX.XXX.XXX." } ] } ] }
The Eventrule has as Action to trigger an Webhook.
- I´ve created an Webhook which does a POST. I´ve added the IP from our Sever who should receive the information. It is http://XXX.XXX.XXX.XXX:XXXX/. HTTP conetent Type is application/json. We´ve added a secret. Timeout is default 60 seconds. SSL Verfication is enabled. No additional Headers and the default Body Template.
- If I update the IP-Address, I can see at Backgroundtask the Keyword Arguments. In those arguments is the user missing:
{'event_rule': <EventRule: Test-Eventrule>, 'object_type': <ObjectType: IPAM > IP Address>, 'event_type': 'object_updated', 'data': {'id': 447, 'url': '/api/ipam/ip-addresses/447/', 'display_url': '/ipam/ip-addresses/447/', 'display': 'XXX.XXX.XXX.XXX/24', 'family': {'value': 4, 'label': 'IPv4'}, 'address': 'XXX.XXX.XXX.XXX/24', 'vrf': None, 'tenant': None, 'status': {'value': 'active', 'label': 'Active'}, 'role': None, 'assigned_object_type': 'dcim.interface', 'assigned_object_id': 4981, 'assigned_object': {'id': 4981, 'url': '/api/dcim/interfaces/4981/', 'display': 'Switch Interface', 'device': {'id': 787, 'url': '/api/dcim/devices/787/', 'display': 'Switch', 'name': 'Switch', 'description': ''}, 'name': 'Switch Interface', 'description': '', 'cable': {'id': 1316, 'url': '/api/dcim/cables/1316/', 'display': '#1316', 'label': '', 'description': ''}, '_occupied': True}, 'nat_inside': None, 'nat_outside': [], 'dns_name': '', 'description': 'description', 'owner': None, 'comments': '', 'tags': [], 'custom_fields': {}, 'created': '2024-09-03T09:15:43.529677+02:00', 'last_updated': '2026-09-23T06:36:39.675179+02:00'}, 'snapshots': {'prechange': {'created': '2024-09-03T07:15:43.529Z', 'owner': None, 'description': '', 'comments': '', 'address': 'XXX.XXX.XXX.XXX/24', 'vrf': None, 'tenant': None, 'status': 'active', 'role': None, 'assigned_object_type': 43, 'assigned_object_id': 4981, 'nat_inside': None, 'dns_name': 'switch name', 'custom_fields': {}, 'tags': []}, 'postchange': {'created': '2024-09-03T07:15:43.529Z', 'owner': None, 'description': 'description', 'comments': '', 'address': 'XXX.XXX.XXX.XXX/24', 'vrf': None, 'tenant': None, 'status': 'active', 'role': None, 'assigned_object_type': 43, 'assigned_object_id': 4981, 'nat_inside': None, 'dns_name': '', 'custom_fields': {}, 'tags': []}}, 'timestamp': '2026-09-23T04:36:39.772210+00:00', 'request': <utilities.request.NetBoxFakeRequest object at 0x7ed6301abae0>}
- Additionally I´ve added this to the Body Template:
{ "user": "{{ request.user }}", "event": "{{ event }}", "object_type": "{{ object_type }}" }
But I still get the same default arguments. Is this a bug or am I doing something wrong?
Expected Behavior
We´ve created an eventrule which triggers a webhook. Our server gets all the information from the webhook. Now a script does different things. If the script has an error a mail will be send. Bevor 4.7.0 we used the user to get the mail address to send them the error Mail. Now the use isn´t available again so we cannot get the Mail-address to send the error Mails to this exact user who triggered the eventrule (changed specific devices).
Observed Behavior
I am only getting the FakeRequest and have no possibility to get the user who triggered the eventrule. I´ve also added "request.user" to the body template but didn´t got the user.
Suspected Cause
The username argument has been removed from extras.webhooks.send_webhook() (the value remains available to webhook templates as request.user). Any webhook jobs still enqueued when the workers are restarted will fail with a TypeError, so the background queues should be allowed to drain before upgrading.
Proposed Fix
No response
Source: netbox-community/netbox