Skip to content

Error in webhook response to include response body #3491

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
candlerb opened this issue Sep 10, 2019 · 0 comments · Fixed by #3888
Closed

Error in webhook response to include response body #3491

candlerb opened this issue Sep 10, 2019 · 0 comments · Fixed by #3888
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application

Comments

@candlerb
Copy link
Contributor

Environment

  • Python version: 3.5.2
  • NetBox version: 2.6.3

Proposed Functionality

At the point where a webhook gets a response code != 2xx, I would like the raised exception to include the response body (response.text) - or the first 1000 characters, say. Alternatively, I'd like the response body to be logged before the exception is raised.

At the moment, all you get is the numeric code and the message "webhook FAILED to process". Example captured from the django-rq admin page after selecting a failed job:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/rq/worker.py", line 812, in perform_job
    rv = job.perform()
  File "/usr/local/lib/python3.5/dist-packages/rq/job.py", line 588, in perform
    self._result = self._execute()
  File "/usr/local/lib/python3.5/dist-packages/rq/job.py", line 594, in _execute
    return self.func(*self.args, **self.kwargs)
  File "/opt/netbox/netbox/extras/webhooks_worker.py", line 58, in process_webhook
    "Status {} returned, webhook FAILED to process.".format(response.status_code)
requests.exceptions.RequestException: Status 500 returned, webhook FAILED to process.

The current code:

        raise requests.exceptions.RequestException(
            "Status {} returned, webhook FAILED to process.".format(response.status_code)
        )

Use Case

Debugging individual job errors at /admin/webhook-backend-status/. The response body might include a useful error message, or even a backtrace from the other side, but this is currently lost.

Database Changes

None

External Dependencies

None

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application labels Oct 17, 2019
jeremystretch added a commit that referenced this issue Jan 13, 2020
Fixes #3491: Include content of webhook error response
@lock lock bot locked as resolved and limited conversation to collaborators Apr 15, 2020
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: feature Introduction of new functionality to the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants