Cascade Webhooks #6589

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

Originally created by @lamoni on GitHub (Jun 23, 2022).

NetBox version

v3.1.5

Feature type

New functionality

Proposed functionality

Have an option for Webhooks firings to "cascade" up from children entities.

E.g. if we have an "Updated" webhook for "DCIM.device" and we modify an interface on that device, I think the dcim.device Update webhook should fire, because the device did technically change. I think should be a checkbox option on the Webhook itself maybe (e.g. "Triggered by children entity changes" or something to that effect)

Use case

We currently have a Create/Delete/Update webhook created for "DCIM.device". I think we should have the option to fire this webhook when a "child" of that device changes (e.g. if we add a new interface, or modify an interface for a device, I think it should fire the "Update" webhook for DCIM.device, because technically that device did change)

I'm open to alternatives (and I'm guessing I've possibly missed something), but the "X" we're trying to solve is: we have a Conditional for the dcim.device to fire, which relies on "tenant". The dcim.interface doesn't have access to it's parent's tenant, so we can't conditionally fire the webhooks for interfaces that belong to devices that belong to a certain tenant via a dcim.interface webhook.

Database changes

Not sure

External dependencies

None

Originally created by @lamoni on GitHub (Jun 23, 2022). ### NetBox version v3.1.5 ### Feature type New functionality ### Proposed functionality Have an option for Webhooks firings to "cascade" up from children entities. E.g. if we have an "Updated" webhook for "DCIM.device" and we modify an interface on that device, I think the dcim.device Update webhook should fire, because the device did technically change. I think should be a checkbox option on the Webhook itself maybe (e.g. "Triggered by children entity changes" or something to that effect) ### Use case We currently have a Create/Delete/Update webhook created for "DCIM.device". I think we should have the option to fire this webhook when a "child" of that device changes (e.g. if we add a new interface, or modify an interface for a device, I think it should fire the "Update" webhook for DCIM.device, because technically that device did change) I'm open to alternatives (and I'm guessing I've possibly missed something), but the "X" we're trying to solve is: we have a Conditional for the dcim.device to fire, which relies on "tenant". The dcim.interface doesn't have access to it's parent's tenant, so we can't conditionally fire the webhooks for interfaces that belong to devices that belong to a certain tenant via a dcim.interface webhook. ### Database changes Not sure ### External dependencies None
adam added the type: featurepending closurestatus: under review labels 2025-12-29 19:42:42 +01:00
adam closed this issue 2025-12-29 19:42:42 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jun 28, 2022):

E.g. if we have an "Updated" webhook for "DCIM.device" and we modify an interface on that device, I think the dcim.device Update webhook should fire, because the device did technically change.

The device didn't change though; only the object being modified did. Consider the extension of your assertion: Should we also fire webhooks for the rack in which the device is installed, and the site at which that rack is located? And if I were to bulk update 48 interfaces, should NetBox send 48 webhook requests for the device, each with the same exact data? I'm sure you see the problems with this approach.

I'd argue that the root of your problem is not being able to reference attributes of related objects within the webhook condition. I imagine ideally you'd do something like this:

{
  "and": [
    {
      "attr": "device.tenant.slug",
      "value": "dunder-mifflin"
    }
  ]
}

This isn't possible today because NetBox includes only the brief/nested representation of related devices in the webhook body:

"device": {
    "id": 94,
    "url": "/api/dcim/devices/94/",
    "display": "ncsu117-distswitch1",
    "name": "ncsu117-distswitch1"
}

IMO it might make sense to extend the default object representation to include the "full" representation of related objects, though I'd have to give more thought to the exact mechanism by which that might be feasible.

@jeremystretch commented on GitHub (Jun 28, 2022): > E.g. if we have an "Updated" webhook for "DCIM.device" and we modify an interface on that device, I think the dcim.device Update webhook should fire, because the device did technically change. The device _didn't_ change though; only the object being modified did. Consider the extension of your assertion: Should we also fire webhooks for the rack in which the device is installed, and the site at which that rack is located? And if I were to bulk update 48 interfaces, should NetBox send 48 webhook requests for the device, each with the same exact data? I'm sure you see the problems with this approach. I'd argue that the root of your problem is not being able to reference attributes of related objects within the webhook condition. I imagine ideally you'd do something like this: ```json { "and": [ { "attr": "device.tenant.slug", "value": "dunder-mifflin" } ] } ``` This isn't possible today because NetBox includes only the brief/nested representation of related devices in the webhook body: ```json "device": { "id": 94, "url": "/api/dcim/devices/94/", "display": "ncsu117-distswitch1", "name": "ncsu117-distswitch1" } ``` IMO it might make sense to extend the default object representation to include the "full" representation of related objects, though I'd have to give more thought to the exact mechanism by which that might be feasible.
Author
Owner

@lamoni commented on GitHub (Jun 28, 2022):

@jeremystretch Definitely agreed, thus why I mentioned the "X" problem part. If we can get access to the full details and can reference that parent data in the conditional, would be ideal. Much appreciated and thanks for considering it!

@lamoni commented on GitHub (Jun 28, 2022): @jeremystretch Definitely agreed, thus why I mentioned the "X" problem part. If we can get access to the full details and can reference that parent data in the conditional, would be ideal. Much appreciated and thanks for considering it!
Author
Owner

@github-actions[bot] commented on GitHub (Aug 28, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Aug 28, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Sep 27, 2022):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Sep 27, 2022): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6589