allow merging lists in config context #9077

Closed
opened 2025-12-29 20:45:07 +01:00 by adam · 3 comments
Owner

Originally created by @szelga on GitHub (Jan 11, 2024).

NetBox version

v3.2.8

Feature type

Change to existing functionality

Proposed functionality

allow deep merging not only dictionaries, but also lists. as of now, netbox replaces lists when merging.

Use case

I'm not saying this feature is universally needed, but there is definitely a use case for this.

I'm using this script to sync Netbox hosts to Zabbix and I want to export Zabbix templates via config context. so, ideally, I'd want, for instance, a source context of the host to be like:

{
    "zabbix": {
        "templates": [
            "ICMP Ping",
            "Linux by Zabbix agent"
        ]
    }
}

the local context

{
    "zabbix": {
        "templates": [
            "Linux generic by Zabbix agent",
            "Linux CPU by Zabbix agent"
        ]
    }
}

and the rendered context

{
    "zabbix": {
        "templates": [
            "ICMP Ping",
            "Linux by Zabbix agent",
            "Linux generic by Zabbix agent",
            "Linux CPU by Zabbix agent"
        ]
    }
}

Database changes

no database changes needed.

External dependencies

deepmerge would be useful in this case, though it's not necessarily required.

Originally created by @szelga on GitHub (Jan 11, 2024). ### NetBox version v3.2.8 ### Feature type Change to existing functionality ### Proposed functionality allow deep merging not only dictionaries, but also lists. as of now, netbox replaces lists when merging. ### Use case I'm not saying this feature is universally needed, but there is definitely a use case for this. I'm using [this script](https://github.com/TheNetworkGuy/netbox-zabbix-sync) to sync Netbox hosts to Zabbix and I want to export Zabbix templates via config context. so, ideally, I'd want, for instance, a source context of the host to be like: ```json { "zabbix": { "templates": [ "ICMP Ping", "Linux by Zabbix agent" ] } } ``` the local context ```json { "zabbix": { "templates": [ "Linux generic by Zabbix agent", "Linux CPU by Zabbix agent" ] } } ``` and the rendered context ```json { "zabbix": { "templates": [ "ICMP Ping", "Linux by Zabbix agent", "Linux generic by Zabbix agent", "Linux CPU by Zabbix agent" ] } } ``` ### Database changes no database changes needed. ### External dependencies [deepmerge](https://deepmerge.readthedocs.io/en/latest/) would be useful in this case, though it's not necessarily required.
adam added the type: featurestatus: revisions needed labels 2025-12-29 20:45:07 +01:00
adam closed this issue 2025-12-29 20:45:08 +01:00
Author
Owner

@abhi1693 commented on GitHub (Jan 11, 2024):

How would you propose a list item to be removed?

@abhi1693 commented on GitHub (Jan 11, 2024): How would you propose a list item to be removed?
Author
Owner

@jeffgdotorg commented on GitHub (Jan 11, 2024):

Thanks for your proposal to help improve NetBox. We need more information to help us evaluate this request. Please take care of the following:

  1. Your report is against a very old version of NetBox. While this functionality has not changed much since, please try in future to open issues against a newer release.
  2. This issue shares many aspects with #5698, which is not to suggest that your issue will have the same outcome.
  3. We need specific suggestions of a convention for how this proposal would work. You might find it useful to refer to the Custom Validators feature for inspiration in the additive use case.
  4. As @abhi1693 points out above, we need your thoughts on how removing a list item might work.
@jeffgdotorg commented on GitHub (Jan 11, 2024): Thanks for your proposal to help improve NetBox. We need more information to help us evaluate this request. Please take care of the following: 1. Your report is against a very old version of NetBox. While this functionality has not changed much since, please try in future to open issues against a newer release. 2. This issue shares many aspects with #5698, which is not to suggest that your issue will have the same outcome. 3. We need specific suggestions of a convention for how this proposal would work. You might find it useful to refer to the [Custom Validators](https://docs.netbox.dev/en/stable/customization/custom-validation/) feature for inspiration in the additive use case. 4. As @abhi1693 points out above, we need your thoughts on how _removing_ a list item might work.
Author
Owner

@jeremystretch commented on GitHub (Jan 24, 2024):

This issue is being closed as no further information has been provided. If you would like to revisit this topic, please first modify your original post to include all the requested detail, and then ask that the issue be reopened.

@jeremystretch commented on GitHub (Jan 24, 2024): This issue is being closed as no further information has been provided. If you would like to revisit this topic, please first modify your original post to include all the requested detail, and then ask that the issue be reopened.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9077