AttributeError exception raised when viewing invalid changelog entry #7257

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

Originally created by @jeremystretch on GitHub (Nov 18, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.3.8

Python version

3.8

Steps to Reproduce

This issue presents itself when an object change record refers to a type of object that no longer exists; e.g. because a plugin has been uninstalled.

Expected Behavior

Rendering a change referring to an unknown object type should fail elegantly, without raising an exception.

Observed Behavior

An AttributeError exception raised when viewing the home page or change log:

AttributeError at /

'NoneType' object has no attribute '_base_manager'
Originally created by @jeremystretch on GitHub (Nov 18, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.3.8 ### Python version 3.8 ### Steps to Reproduce This issue presents itself when an object change record refers to a type of object that no longer exists; e.g. because a plugin has been uninstalled. ### Expected Behavior Rendering a change referring to an unknown object type should fail elegantly, without raising an exception. ### Observed Behavior An AttributeError exception raised when viewing the home page or change log: ``` AttributeError at / 'NoneType' object has no attribute '_base_manager' ```
adam added the type: bugstatus: accepted labels 2025-12-29 20:20:56 +01:00
adam closed this issue 2025-12-29 20:20:56 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 21, 2022):

This is revisiting the root problem originally captured in #7149.

@jeremystretch commented on GitHub (Nov 21, 2022): This is revisiting the root problem originally captured in #7149.
Author
Owner

@jeremystretch commented on GitHub (Nov 21, 2022):

Unfortunately I haven't been able to find any clever solution to this problem: The exception originates deep within the queryset and is due to prefetching a GFK for an object type which no longer exists. As this scenario arises only in very particular circumstances (i.e. when a previously existing model has been removed without cleaning up the database) and is itself non-destructive, I'm okay with leaving it as-is. Perhaps a future release of Django will make this more feasible to tackle.

@jeremystretch commented on GitHub (Nov 21, 2022): Unfortunately I haven't been able to find any clever solution to this problem: The exception originates deep within the queryset and is due to prefetching a GFK for an object type which no longer exists. As this scenario arises only in very particular circumstances (i.e. when a previously existing model has been removed without cleaning up the database) and is itself non-destructive, I'm okay with leaving it as-is. Perhaps a future release of Django will make this more feasible to tackle.
Author
Owner

@pdenessen commented on GitHub (Nov 22, 2022):

Hi Jeremy, is there a way to include a clean-up script then which checks the log and removes wrong entries which causes this error?

@pdenessen commented on GitHub (Nov 22, 2022): Hi Jeremy, is there a way to include a clean-up script then which checks the log and removes wrong entries which causes this error?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7257