Webhooks break when header value contains a ':' #4718

Closed
opened 2025-12-29 19:19:50 +01:00 by adam · 2 comments
Owner

Originally created by @friek on GitHub (Apr 2, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.10.8

Python version

3.9

Steps to Reproduce

  1. Create a webhook in Django admin (probably any will do)
  2. In the "Additional headers" enter: Header: 1:2
  3. Trigger the webhook

Expected Behavior

The webhook should be called with the configured headers

Observed Behavior

The webhook raises an exception and is not calling the configured URL:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/rq/worker.py", line 1008, in perform_job
    rv = job.perform()
  File "/usr/local/lib/python3.9/site-packages/rq/job.py", line 706, in perform
    self._result = self._execute()
  File "/usr/local/lib/python3.9/site-packages/rq/job.py", line 729, in _execute
    result = self.func(*self.args, **self.kwargs)
  File "/opt/netbox/netbox/extras/webhooks_worker.py", line 36, in process_webhook
    raise e
  File "/opt/netbox/netbox/extras/webhooks_worker.py", line 33, in process_webhook
    headers.update(webhook.render_headers(context))
  File "/opt/netbox/netbox/extras/models/models.py", line 143, in render_headers
    header, value = line.split(':')
ValueError: too many values to unpack (expected 2)

I've forked the current develop branch and have a fix in place locally, including a working test case. I can submit a pull request if you like.

Originally created by @friek on GitHub (Apr 2, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.10.8 ### Python version 3.9 ### Steps to Reproduce 1. Create a webhook in Django admin (probably any will do) 2. In the "Additional headers" enter: Header: 1:2 3. Trigger the webhook ### Expected Behavior The webhook should be called with the configured headers ### Observed Behavior The webhook raises an exception and is not calling the configured URL: ``` Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/rq/worker.py", line 1008, in perform_job rv = job.perform() File "/usr/local/lib/python3.9/site-packages/rq/job.py", line 706, in perform self._result = self._execute() File "/usr/local/lib/python3.9/site-packages/rq/job.py", line 729, in _execute result = self.func(*self.args, **self.kwargs) File "/opt/netbox/netbox/extras/webhooks_worker.py", line 36, in process_webhook raise e File "/opt/netbox/netbox/extras/webhooks_worker.py", line 33, in process_webhook headers.update(webhook.render_headers(context)) File "/opt/netbox/netbox/extras/models/models.py", line 143, in render_headers header, value = line.split(':') ValueError: too many values to unpack (expected 2) ``` I've forked the current develop branch and have a fix in place locally, including a working test case. I can submit a pull request if you like.
adam added the type: bugstatus: accepted labels 2025-12-29 19:19:50 +01:00
adam closed this issue 2025-12-29 19:19:50 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 7, 2021):

@friek Sure thing, please feel free to submit a PR. I've assigned this bug to you. Thanks for the report!

@jeremystretch commented on GitHub (Apr 7, 2021): @friek Sure thing, please feel free to submit a PR. I've assigned this bug to you. Thanks for the report!
Author
Owner

@jeremystretch commented on GitHub (Apr 12, 2021):

It's a minor fix so I'm just going to go ahead and knock this out for v2.10.9.

@jeremystretch commented on GitHub (Apr 12, 2021): It's a minor fix so I'm just going to go ahead and knock this out for v2.10.9.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4718