Server Error on User Detail Page #9765

Closed
opened 2025-12-29 21:22:19 +01:00 by adam · 2 comments
Owner

Originally created by @Kani999 on GitHub (May 29, 2024).

Deployment Type

Self-hosted

NetBox Version

v4.0.3

Python Version

3.10

Steps to Reproduce

Description

When accessing certain users in NetBox at the URL users/users/45/, the following error is displayed:

Server Error 
<class 'AttributeError'>
'NoneType' object has no attribute '_base_manager'

Problem

The issue arises because the ChangeLog is displayed for the object. After investigating, I found the following details:

Steps to Reproduce

  1. Open the NetBox shell.
  2. Retrieve the user with the problematic ID:
x = User.objects.get(id=45) # user with a problem
all_changes = ObjectChange.objects.filter(user_id=x.id)
# <ObjectChangeQuerySet [<ObjectChange: individualoptions IndividualOptions object (11) created by USERNAME>]>
# Now I select the individualoption object change
error_changelog = all_changes.first()
  1. Attempt to clean the object change:
>>> error_changelog.full_clean()
Traceback (most recent call last):
  File "/usr/lib/python3.11/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/opt/netbox/venv/lib/python3.11/site-packages/django/db/models/base.py", line 1556, in full_clean
    raise ValidationError(errors)
django.core.exceptions.ValidationError: {'__all__': ['Change logging is not supported for this object type (individualoptions).']}
  1. Delete the problematic change log entry
error_changelog.delete()
  1. After deleting the entry, I can access the user detail in the browser without errors.

Summary

The issue is due to rendering an invalid ChangeLog entry, which should not be supported but is stored in the database.

Suggested Solution

Investigate and fix the logic that incorrectly allows unsupported change logs to be stored, and ensure existing invalid entries are handled appropriately to prevent similar errors.

Expected Behavior

When accessing the user detail page at users/users/45/, the user details should be displayed without any errors. The page should load correctly, showing all relevant user information and associated logs that are supported by the system.

What did you expect to happen?

  • The user detail page should render successfully.
  • The ChangeLog should only display entries that are supported and valid for the object type.
  • There should be no server errors or exceptions preventing access to the user detail page.

Observed Behavior

When accessing the user detail page at users/users/45/, a server error is encountered:

Server Error 
<class 'AttributeError'>
'NoneType' object has no attribute '_base_manager'

The page fails to load correctly due to an invalid ChangeLog entry associated with the user. The error occurs because the ChangeLog is attempting to render an object type (individualoptions) that is not supported for change logging, resulting in an AttributeError.

Originally created by @Kani999 on GitHub (May 29, 2024). ### Deployment Type Self-hosted ### NetBox Version v4.0.3 ### Python Version 3.10 ### Steps to Reproduce ## Description When accessing certain users in NetBox at the URL users/users/45/, the following error is displayed: ```typescript Server Error <class 'AttributeError'> 'NoneType' object has no attribute '_base_manager' ``` ## Problem The issue arises because the `ChangeLog` is displayed for the object. After investigating, I found the following details: ### Steps to Reproduce 1. Open the NetBox shell. 2. Retrieve the user with the problematic ID: ```python x = User.objects.get(id=45) # user with a problem all_changes = ObjectChange.objects.filter(user_id=x.id) # <ObjectChangeQuerySet [<ObjectChange: individualoptions IndividualOptions object (11) created by USERNAME>]> # Now I select the individualoption object change error_changelog = all_changes.first() ``` 3. Attempt to clean the object change: ```python >>> error_changelog.full_clean() Traceback (most recent call last): File "/usr/lib/python3.11/code.py", line 90, in runcode exec(code, self.locals) File "<console>", line 1, in <module> File "/opt/netbox/venv/lib/python3.11/site-packages/django/db/models/base.py", line 1556, in full_clean raise ValidationError(errors) django.core.exceptions.ValidationError: {'__all__': ['Change logging is not supported for this object type (individualoptions).']} ``` 4. Delete the problematic change log entry ```python error_changelog.delete() ``` 5. After deleting the entry, I can access the user detail in the browser without errors. ## Summary The issue is due to rendering an invalid ChangeLog entry, which should not be supported but is stored in the database. ## Suggested Solution Investigate and fix the logic that incorrectly allows unsupported change logs to be stored, and ensure existing invalid entries are handled appropriately to prevent similar errors. ### Expected Behavior When accessing the user detail page at users/users/45/, the user details should be displayed without any errors. The page should load correctly, showing all relevant user information and associated logs that are supported by the system. What did you expect to happen? - The user detail page should render successfully. - The ChangeLog should only display entries that are supported and valid for the object type. - There should be no server errors or exceptions preventing access to the user detail page. ### Observed Behavior When accessing the user detail page at users/users/45/, a server error is encountered: ```typescript Server Error <class 'AttributeError'> 'NoneType' object has no attribute '_base_manager' ``` The page fails to load correctly due to an invalid ChangeLog entry associated with the user. The error occurs because the ChangeLog is attempting to render an object type (individualoptions) that is not supported for change logging, resulting in an AttributeError.
adam closed this issue 2025-12-29 21:22:20 +01:00
Author
Owner

@Kani999 commented on GitHub (May 29, 2024):

Okay, so It's not a core NetBox problem. It's a problem with NetBox Topology Views plugin.
IndividualOption model is defined in the plugin.

Workaround:

# enter nbshell
individual_option = ObjectType.objects.get(model='individualoptions')
changes = ObjectChange.objects.filter(changed_object_type_id = individual_option.id)
changes.delete()

After deleting the changes everything works just fine.

@Kani999 commented on GitHub (May 29, 2024): Okay, so It's not a core NetBox problem. It's a problem with NetBox Topology Views plugin. IndividualOption model is defined in the plugin. Workaround: ```python # enter nbshell individual_option = ObjectType.objects.get(model='individualoptions') changes = ObjectChange.objects.filter(changed_object_type_id = individual_option.id) changes.delete() ``` After deleting the changes everything works just fine.
Author
Owner

@Kani999 commented on GitHub (May 29, 2024):

Maybe in the section Plugin Removal of the documentation, there should be a part that mentions the need to remove "stale" changelogs after plugin removal. Failing to do so could potentially cause problems in the future.

@Kani999 commented on GitHub (May 29, 2024): Maybe in the section [Plugin Removal](https://netboxlabs.com/docs/netbox/en/stable/plugins/removal) of the documentation, there should be a part that mentions the need to remove "stale" changelogs after plugin removal. Failing to do so could potentially cause problems in the future.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9765