Skip to content

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

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

Closed
friek opened this issue Apr 2, 2021 · 2 comments
Closed

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

friek opened this issue Apr 2, 2021 · 2 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@friek
Copy link

friek commented Apr 2, 2021

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.

@friek friek added the type: bug A confirmed report of unexpected behavior in the application label Apr 2, 2021
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Apr 7, 2021
@jeremystretch jeremystretch self-assigned this Apr 7, 2021
@jeremystretch
Copy link
Member

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

@jeremystretch
Copy link
Member

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants