Description
Deployment Type
Self-hosted
NetBox Version
v4.2.3
Python Version
3.12
Steps to Reproduce
- Create multiple custom_fields with object type IPAM > Prefix
- primary_subnet, type: boolean, required: yes, default value: true
- ripe_admin, type: text, required: no, default value: "xxx-RIPE"
- ripe_tech, type: text, required:no
- ripe_netname, type: text, required: no
- Create a new prefix using API without custom_fields
{ "prefix": "10.0.0.0/24", "status": "active", "description": "Test prefix", "vlan": "147", "is_pool": false, "tenant": 6 }
- Create a new prefix using API with only "primary_subnet" as custom_field
{ "prefix": "10.0.0.0/24", "status": "active", "description": "Test prefix", "vlan": "147", "is_pool": false, "tenant": 6, "custom_fields": { "primary_subnet": true } }
- Create a new prefix using API with only "ripe_netname" as custom_field
{ "prefix": "10.0.0.0/24", "status": "active", "description": "Test prefix", "vlan": "147", "is_pool": false, "tenant": 6, "custom_fields": { "ripe_netname": "test" } }
Expected Behavior
- Custom fields are created
- Prefix is created with default values for custom_fields primary_subnet and ripe_admin. Other custom_fields are null
- Prefix is created with supplied value for custom_field primary_subnet, default value for ripe_admin. Other custom_fields are null
- Prefix is created with default values for custom_fields primary_subnet and ripe_admin. ripe_netname gets the supplied value and ripe_tech remains null
Observed Behavior
As soon as a custom_fields section is available in the POST Body then the default values for all custom_fields are ignored.
When I do not send the custom_fields section at all then the default values are used correctly.
- Custom fields are created (OK)
- Prefix is created with default values for primary_subnet and ripe_admin (OK)
- Prefix is created with primary_subnet set to true but other custom_fields are empty -> default value for ripe_admin is ignored
- Prefix is not created because primary_subnet (required) is not supplied -> default value for primary_subnet is ignored