Handle exception when a webhook is triggered but Redis is unreachable #3330

Closed
opened 2025-12-29 18:27:46 +01:00 by adam · 2 comments
Owner

Originally created by @jeremystretch on GitHub (Feb 14, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.6.9
  • NetBox version: 2.7.6

Proposed Functionality

When NetBox attempts to enqueue a webhook and Redis is unreachable, an exception is raised:

  File "/home/jstretch/.virtualenvs/netbox/lib/python3.6/site-packages/redis/connection.py", line 544, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.

We should handle this exception and do something in response, but I'm not sure yet what that is. Current options include:

  1. Continue with the action and present a warning message on the UI that a webhook was not sent. (Not sure how we'd convey the failure to an API consumer though.)
  2. Abort the action with an error message (seems extreme).
  3. Maintain the current behavior of displaying an error page (after applying the change), but with more contextual help around fixing Redis.

I'm open to other suggestions.

Use Case

Provide a better user experience and recovery path in the event of a Redis failure.

Database Changes

None

External Dependencies

None

Originally created by @jeremystretch on GitHub (Feb 14, 2020). Originally assigned to: @jeremystretch on GitHub. ### Environment * Python version: 3.6.9 * NetBox version: 2.7.6 ### Proposed Functionality When NetBox attempts to enqueue a webhook and Redis is unreachable, an exception is raised: ``` File "/home/jstretch/.virtualenvs/netbox/lib/python3.6/site-packages/redis/connection.py", line 544, in connect raise ConnectionError(self._error_message(e)) redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused. ``` We should handle this exception and do _something_ in response, but I'm not sure yet what that is. Current options include: 1) Continue with the action and present a warning message on the UI that a webhook was not sent. (Not sure how we'd convey the failure to an API consumer though.) 2) Abort the action with an error message (seems extreme). 3) Maintain the current behavior of displaying an error page (after applying the change), but with more contextual help around fixing Redis. I'm open to other suggestions. ### Use Case Provide a better user experience and recovery path in the event of a Redis failure. ### Database Changes None ### External Dependencies None
adam added the status: acceptedtype: feature labels 2025-12-29 18:27:46 +01:00
adam closed this issue 2025-12-29 18:27:46 +01:00
Author
Owner

@sdktr commented on GitHub (Feb 20, 2020):

Implement 1 or 2 depending on a boolean set on the webhook?
allow_updates_on_webhook_failure
True -> 1
False -> 2

@sdktr commented on GitHub (Feb 20, 2020): Implement 1 or 2 depending on a boolean set on the webhook? `allow_updates_on_webhook_failure` True -> 1 False -> 2
Author
Owner

@jeremystretch commented on GitHub (Feb 21, 2020):

I opted to go with option 1, because it conveys the need for attention to the user without disrupting the workflow. Option 2 seems needlessly harsh, and option 3 would be too disruptive and lead the user to question whether the action itself was successful.

Screenshot_2020-02-21 Devices - NetBox

@jeremystretch commented on GitHub (Feb 21, 2020): I opted to go with option 1, because it conveys the need for attention to the user without disrupting the workflow. Option 2 seems needlessly harsh, and option 3 would be too disruptive and lead the user to question whether the action itself was successful. ![Screenshot_2020-02-21 Devices - NetBox](https://user-images.githubusercontent.com/13487278/75076400-10331200-54ce-11ea-8e10-06f4bd68fb44.png)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3330