Skip to content

When adding a Custom Field via API it does not accept null values for non-required fields in version 3.7.0 #14778

@ariandres

Description

@ariandres

Deployment Type

Self-hosted

NetBox Version

v3.7.0

Python Version

3.8

Steps to Reproduce

  1. An error is generated when a request is sent to create a Custom Field
curl -X 'POST' \
  'http://0.0.0.0/api/extras/custom-fields/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'X-CSRFTOKEN: zM1Spw2GkaObXREv7mZHEvlIXdN7oG2sb8dGpmtta8x34hvg1Hjqnzwn24MqYOCR' \
  -d '{
  "content_types": [
    "dcim.rearport"
  ],
  "type": "text",
  "object_type": null,
  "name": "Test",
  "label": "string",
  "group_name": "string",
  "description": "string",
  "required": true,
  "search_weight": 32767,
  "filter_logic": "disabled",
  "ui_visible": "always",
  "ui_editable": "yes",
  "is_cloneable": true,
  "default": "string",
  "weight": 32767,
  "validation_minimum": null,
  "validation_maximum": null,
  "validation_regex": "string",
  "choice_set": null
}'

Expected Behavior

Add the Custom Field as defined.

Observed Behavior

The following error occurs when the request is submitted:

Code: 400
Details: Error: Bad Request
Response body:

{
  "object_type": [
    "This field may not be null."
  ],
  "choice_set": [
    "This field may not be null."
  ]
}

If the fields are removed from the request the behavior is as expected, however it is not a solution since I do not directly control what is sent in the HTTP request and it would not allow passing the fields from a non-null value to a null one.

Adding an Custom Field via GUI is not a problem (only the required fields are filled)

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions