Legacy actions for views no longer working in NetBox 4.4.0 #11580

Closed
opened 2025-12-29 21:47:06 +01:00 by adam · 7 comments
Owner

Originally created by @peteeckel on GitHub (Sep 5, 2025).

Deployment Type

Self-hosted

NetBox Version

v4.4.0

Python Version

3.12

Steps to Reproduce

  1. Install NetBox DNS 1.4.0 on a NetBox 4.4.0 system
  2. Create a nameserver and an arbitrary zone
  3. Click on the zone's 'Managed Records' tab

Expected Behavior

The zone's managed records are displayed.

Observed Behavior

Image

See also https://github.com/peteeckel/netbox-plugin-dns/issues/703.

This error message is caused by a breaking change between NetBox 4.3.7 and NetBox 4.4.0. The code was working in NetBox 4.3.7 (although deprecated, which is definitely my fault). NetBox 4.4.0 should, however, not introduce any breaking changes as it was documented in https://github.com/netbox-community/netbox/discussions/19899.

Originally created by @peteeckel on GitHub (Sep 5, 2025). ### Deployment Type Self-hosted ### NetBox Version v4.4.0 ### Python Version 3.12 ### Steps to Reproduce 1. Install NetBox DNS 1.4.0 on a NetBox 4.4.0 system 2. Create a nameserver and an arbitrary zone 3. Click on the zone's 'Managed Records' tab ### Expected Behavior The zone's managed records are displayed. ### Observed Behavior <img width="226" height="136" alt="Image" src="https://github.com/user-attachments/assets/9583fbec-97f2-4b0a-8a8a-f250c4850e0a" /> See also https://github.com/peteeckel/netbox-plugin-dns/issues/703. This error message is caused by a breaking change between NetBox 4.3.7 and NetBox 4.4.0. The code was working in NetBox 4.3.7 (although deprecated, which is definitely my fault). NetBox 4.4.0 should, however, not introduce any breaking changes as it was documented in https://github.com/netbox-community/netbox/discussions/19899.
adam added the type: bug label 2025-12-29 21:47:06 +01:00
adam closed this issue 2025-12-29 21:47:06 +01:00
Author
Owner

@arthanson commented on GitHub (Sep 8, 2025):

@peteeckel can you please provide details on what url, API call or view is causing this issue. What is the change in NetBox that is breaking?

@arthanson commented on GitHub (Sep 8, 2025): @peteeckel can you please provide details on what url, API call or view is causing this issue. What is the change in NetBox that is breaking?
Author
Owner

@rfdrake commented on GitHub (Sep 10, 2025):

The code this is triggering is in netbox/netbox/views/generic/mixins.py

git diff v4.3.7..v4.4.0 netbox/netbox/views/generic/mixins.py

LEGACY_ACTIONS doesn't have a fallback, and "changelog" wasn't one of the allowed legacy actions.

This probably won't affect too many people. @peteeckel already released a new version of netbox-dns which fixes the problem, but some plugin authors may need to be aware of what they need to do if they get this message.

@rfdrake commented on GitHub (Sep 10, 2025): The code this is triggering is in netbox/netbox/views/generic/mixins.py git diff v4.3.7..v4.4.0 netbox/netbox/views/generic/mixins.py LEGACY_ACTIONS doesn't have a fallback, and "changelog" wasn't one of the allowed legacy actions. This probably won't affect too many people. @peteeckel already released a new version of netbox-dns which fixes the problem, but some plugin authors may need to be aware of what they need to do if they get this message.
Author
Owner

@peteeckel commented on GitHub (Sep 10, 2025):

@rfdrake Thanks, that's exactly the place where it occurred.

The piece of code causing it was

@register_model_view(Zone, "managed_records")
class ZoneManagedRecordListView(generic.ObjectChildrenView):
    queryset = Zone.objects.all()
    child_model = Record
    table = ManagedRecordTable
    filterset = RecordFilterSet
    template_name = "netbox_dns/zone/managed_record.html"
    actions = {"changelog": {"view"}}

    tab = ViewTab(
        label=_("Managed Records"),
        permission="netbox_dns.view_record",
        badge=lambda obj: obj.records.filter(managed=True).count(),
        hide_if_empty=True,
    )

    def get_children(self, request, parent):
        return parent.records.restrict(request.user, "view").filter(managed=True)

At some point in time (the "actions" definition was more than two years old, and at the time of writing I needed it to enable the change log button in the list of managed records) apparently allowing the change log action became obsolete without me being aware of it, so the line lingered around there until 4.4.0 finally broke it.

Probably this wasn't widely used, I agree.

In the mean time, I added test cases for all view tabs so something like this won't go unnoticed again.

@peteeckel commented on GitHub (Sep 10, 2025): @rfdrake Thanks, that's exactly the place where it occurred. The piece of code causing it was ```python @register_model_view(Zone, "managed_records") class ZoneManagedRecordListView(generic.ObjectChildrenView): queryset = Zone.objects.all() child_model = Record table = ManagedRecordTable filterset = RecordFilterSet template_name = "netbox_dns/zone/managed_record.html" actions = {"changelog": {"view"}} tab = ViewTab( label=_("Managed Records"), permission="netbox_dns.view_record", badge=lambda obj: obj.records.filter(managed=True).count(), hide_if_empty=True, ) def get_children(self, request, parent): return parent.records.restrict(request.user, "view").filter(managed=True) ``` At some point in time (the "actions" definition was more than two years old, and at the time of writing I needed it to enable the change log button in the list of managed records) apparently allowing the change log action became obsolete without me being aware of it, so the line lingered around there until 4.4.0 finally broke it. Probably this wasn't widely used, I agree. In the mean time, I added test cases for all view tabs so something like this won't go unnoticed again.
Author
Owner

@jeremystretch commented on GitHub (Sep 10, 2025):

@peteeckel I'm not clear on how "changelog" would be an action as it doesn't deal with the creation, modification, or deletion of objects. I made sure to implement backward compatibility for legacy actions in v4.4, but that's limited to the expected actions (add, edit, delete, etc.).

bf7356473c/netbox/netbox/views/generic/mixins.py (L12-L22)

I'm not sure there's anything we can do to address this in core, as it wouldn't make sense to create a "Changelog" action.

@jeremystretch commented on GitHub (Sep 10, 2025): @peteeckel I'm not clear on how "changelog" would be an action as it doesn't deal with the creation, modification, or deletion of objects. I made sure to implement backward compatibility for legacy actions in v4.4, but that's limited to the expected actions (add, edit, delete, etc.). https://github.com/netbox-community/netbox/blob/bf7356473c8dd8eb08c202e3f5f78cb42c686484/netbox/netbox/views/generic/mixins.py#L12-L22 I'm not sure there's anything we can do to address this in core, as it wouldn't make sense to create a "Changelog" action.
Author
Owner

@peteeckel commented on GitHub (Sep 10, 2025):

I just went back to the v4.0.0 tag, and in netbox/netbox/tables/columns.py there is the following code:

215 class ActionsColumn(tables.Column):
216     """
217     A dropdown menu which provides edit, delete, and changelog links for an object. Can optionally include
218     additional buttons rendered from a template string.
219 
220     :param actions: The ordered list of dropdown menu items to include
221     :param extra_buttons: A Django template string which renders additional buttons preceding the actions dropdown
222     :param split_actions: When True, converts the actions dropdown menu into a split button with first action as the
223         direct button link and icon (default: True)
224     """
225     attrs = {'td': {'class': 'text-end text-nowrap noprint'}}
226     empty_values = ()
227     actions = {
228         'edit': ActionsItem('Edit', 'pencil', 'change', 'warning'),
229         'delete': ActionsItem('Delete', 'trash-can-outline', 'delete', 'danger'),
230         'changelog': ActionsItem('Changelog', 'history'),
231     }
232 
233     def __init__(self, *args, actions=('edit', 'delete', 'changelog'), extra_buttons='', split_actions=True, **kwargs):
234         super().__init__(*args, **kwargs)
235 
236         self.extra_buttons = extra_buttons
237         self.split_actions = split_actions
238 
239         # Determine which actions to enable
240         self.actions = {
241             name: self.actions[name] for name in actions
242         }

So there used to be a changelog action back then. I don't remember exactly why I came to this conclusion, but the plugin code I just removed was necessary to display the changelog action button but not the edit and delete buttons.

@peteeckel commented on GitHub (Sep 10, 2025): I just went back to the v4.0.0 tag, and in `netbox/netbox/tables/columns.py` there is the following code: ```python 215 class ActionsColumn(tables.Column): 216 """ 217 A dropdown menu which provides edit, delete, and changelog links for an object. Can optionally include 218 additional buttons rendered from a template string. 219 220 :param actions: The ordered list of dropdown menu items to include 221 :param extra_buttons: A Django template string which renders additional buttons preceding the actions dropdown 222 :param split_actions: When True, converts the actions dropdown menu into a split button with first action as the 223 direct button link and icon (default: True) 224 """ 225 attrs = {'td': {'class': 'text-end text-nowrap noprint'}} 226 empty_values = () 227 actions = { 228 'edit': ActionsItem('Edit', 'pencil', 'change', 'warning'), 229 'delete': ActionsItem('Delete', 'trash-can-outline', 'delete', 'danger'), 230 'changelog': ActionsItem('Changelog', 'history'), 231 } 232 233 def __init__(self, *args, actions=('edit', 'delete', 'changelog'), extra_buttons='', split_actions=True, **kwargs): 234 super().__init__(*args, **kwargs) 235 236 self.extra_buttons = extra_buttons 237 self.split_actions = split_actions 238 239 # Determine which actions to enable 240 self.actions = { 241 name: self.actions[name] for name in actions 242 } ``` So there used to be a `changelog` action back then. I don't remember exactly why I came to this conclusion, but the plugin code I just removed was necessary to display the changelog action button but not the edit and delete buttons.
Author
Owner

@jeremystretch commented on GitHub (Sep 10, 2025):

The generic object changelog view (ObjectChangeLogView) has been registered automatically since v3.4. The default changelog appears to have been left over from prior releases.

Apologies for the unintended breakage, but I don't think there's anything we can to do address this in core. It appears you've addresses it in the plugin by simply removing the offending line, so I'm going to close this out.

@jeremystretch commented on GitHub (Sep 10, 2025): The generic object changelog view (`ObjectChangeLogView`) has been registered automatically since v3.4. The default `changelog` appears to have been left over from prior releases. Apologies for the unintended breakage, but I don't think there's anything we can to do address this in core. It appears you've addresses it in the plugin by simply [removing the offending line](https://github.com/peteeckel/netbox-plugin-dns/pull/704/files), so I'm going to close this out.
Author
Owner

@peteeckel commented on GitHub (Sep 11, 2025):

The generic object changelog view (ObjectChangeLogView) has been registered automatically since v3.4. The default changelog appears to have been left over from prior releases.

Apologies for the unintended breakage, but I don't think there's anything we can to do address this in core. It appears you've addresses it in the plugin by simply removing the offending line, so I'm going to close this out.

The changelog action was introduced in the plugin with version 0.16.0 back in December 2022, which was the release that added support for NetBox 3.4.0.

As it's not in the native list view but only in the list view tab for the managed records of a zone I faintly remember that with 3.4.0 the changelog buttons had disappeared from that view and adding the changelog action (at that time in the old list-based syntax instead of the dictionary-based one introduced later) was the way to get them back. Apparently I missed a subsequent change that brought them back by default.

@register_model_view(Zone, "managed_records")
class ZoneManagedRecordListView(generic.ObjectChildrenView):
    queryset = Zone.objects.all()
    child_model = Record
    table = ManagedRecordTable
    filterset = RecordFilter
    template_name = "netbox_dns/zone/managed_record.html"
    actions = ("changelog",)

[...]

Anyway, thanks for clarifying this and yes, the fix was easy to do and I released a new version the same hour the problem was detected.

@peteeckel commented on GitHub (Sep 11, 2025): > The generic object changelog view (`ObjectChangeLogView`) has been registered automatically since v3.4. The default `changelog` appears to have been left over from prior releases. > > Apologies for the unintended breakage, but I don't think there's anything we can to do address this in core. It appears you've addresses it in the plugin by simply [removing the offending line](https://github.com/peteeckel/netbox-plugin-dns/pull/704/files), so I'm going to close this out. The `changelog` action was introduced in the plugin with version 0.16.0 back in December 2022, which was the release that added support for NetBox 3.4.0. As it's not in the native list view but only in the list view tab for the managed records of a zone I faintly remember that with 3.4.0 the changelog buttons had disappeared from that view and adding the `changelog` action (at that time in the old list-based syntax instead of the dictionary-based one introduced later) was the way to get them back. Apparently I missed a subsequent change that brought them back by default. ```python @register_model_view(Zone, "managed_records") class ZoneManagedRecordListView(generic.ObjectChildrenView): queryset = Zone.objects.all() child_model = Record table = ManagedRecordTable filterset = RecordFilter template_name = "netbox_dns/zone/managed_record.html" actions = ("changelog",) [...] ``` Anyway, thanks for clarifying this and yes, the fix was easy to do and I released a new version the same hour the problem was detected.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11580