Default values for object custom fields are not checked for validity #7963

Closed
opened 2025-12-29 20:30:33 +01:00 by adam · 0 comments
Owner

Originally created by @amhn on GitHub (Apr 29, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.5.0

Python version

3.11

Steps to Reproduce

  1. Create e.g. Prefix
  2. Create Custom-Field with content type Prefix, type object, Object type e.g. IP address and default [1]
  3. Go to previously created prefix

Expected Behavior

Creation of custom field is aborted because default value is not valid for this type. The default value should be an int instead of a list.

Even better: default object is checked for existence. This does not guarantee that the object exists later, because it could be deleted later.

Observed Behavior

Custom field is created and the previously create prefix can not be viewed:
image

If the default value is syntactically correct but the object does not exist, the value for the custom field is displayed as null

Same goes for a multi-object custom field with a single int as default, except for a different error message:
'int' object is not iterable

Originally created by @amhn on GitHub (Apr 29, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.5.0 ### Python version 3.11 ### Steps to Reproduce 1. Create e.g. Prefix 2. Create Custom-Field with content type Prefix, type object, Object type e.g. IP address and default `[1]` 3. Go to previously created prefix ### Expected Behavior Creation of custom field is aborted because default value is not valid for this type. The default value should be an int instead of a list. Even better: default object is checked for existence. This does not guarantee that the object exists later, because it could be deleted later. ### Observed Behavior Custom field is created and the previously create prefix can not be viewed: ![image](https://user-images.githubusercontent.com/67868947/235320789-98edabb7-4882-4e17-955f-a2b262d5f618.png) If the default value is syntactically correct but the object does not exist, the value for the custom field is displayed as `null` Same goes for a multi-object custom field with a single int as default, except for a different error message: `'int' object is not iterable`
adam added the type: bugstatus: accepted labels 2025-12-29 20:30:33 +01:00
adam closed this issue 2025-12-29 20:30:33 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7963