NetBox Edition
NetBox Community
NetBox Version
v4.6.0
Python Version
3.12
Steps to Reproduce
-
Log in as a user with the extras.add_tableconfig permission.
-
Browse directly to the standalone Add URL, without going through a
"Save table configuration" button on an existing table list view:
GET /extras/table-configs/add/
Expected Behavior
The Add page should load without a server error. The form should either prompt the user to first choose an object_type and table (then populate the column selectors based on the chosen table), or redirect the user back to the parent table's list view where the Save Configuration action lives. Forms that derive widget choices from a related field should guard the related lookup so that the form is still constructible before the user has
picked a value.
Observed Behavior
The view returns HTTP 500 and the server log shows core.models.object_types.ObjectType.DoesNotExist raised during form rendering:
core.models.object_types.ObjectType.DoesNotExist: ObjectType matching query does not exist.
The traceback ends in TableConfigForm.__init__:
# netbox/extras/forms/model_forms.py
class TableConfigForm(forms.ModelForm):
...
def __init__(self, data=None, *args, **kwargs):
super().__init__(data, *args, **kwargs)
object_type = ObjectType.objects.get(pk=get_field_value(self, 'object_type')) # ← raises
model = object_type.model_class()
...
The lookup is unconditional. When the form has no bound POST data, no initial data, and no instance, get_field_value(self, 'object_type') returns None and the get() call raises DoesNotExist.
A small guard preserves current behavior for the "Save table configuration" flow while making the form usable from the standalone Add URL:
def __init__(self, data=None, *args, **kwargs):
super().__init__(data, *args, **kwargs)
object_type_pk = get_field_value(self, 'object_type')
if not object_type_pk:
return
object_type = ObjectType.objects.get(pk=object_type_pk)
...
This was surfaced while adding standard test coverage for extras.tableconfig in #22088. The housekeeping PR currently exempts the affected view coverage with a self-cleaning marker that will prompt removal once this issue is fixed.
NetBox Edition
NetBox Community
NetBox Version
v4.6.0
Python Version
3.12
Steps to Reproduce
Log in as a user with the
extras.add_tableconfigpermission.Browse directly to the standalone Add URL, without going through a
"Save table configuration" button on an existing table list view:
Expected Behavior
The Add page should load without a server error. The form should either prompt the user to first choose an
object_typeandtable(then populate the column selectors based on the chosen table), or redirect the user back to the parent table's list view where the Save Configuration action lives. Forms that derive widget choices from a related field should guard the related lookup so that the form is still constructible before the user haspicked a value.
Observed Behavior
The view returns HTTP 500 and the server log shows
core.models.object_types.ObjectType.DoesNotExistraised during form rendering:The traceback ends in
TableConfigForm.__init__:The lookup is unconditional. When the form has no bound POST data, no initial data, and no instance,
get_field_value(self, 'object_type')returnsNoneand theget()call raisesDoesNotExist.A small guard preserves current behavior for the "Save table configuration" flow while making the form usable from the standalone Add URL:
This was surfaced while adding standard test coverage for
extras.tableconfigin #22088. The housekeeping PR currently exempts the affected view coverage with a self-cleaning marker that will prompt removal once this issue is fixed.