Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ariandres opened this issue Jan 11, 2024 · 2 comments · Fixed by #14807
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@ariandres
Copy link

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)

@ariandres ariandres added the type: bug A confirmed report of unexpected behavior in the application label Jan 11, 2024
@ariandres
Copy link
Author

Field Choice Set has the same behavior with the "base_choices" field

@jeremystretch jeremystretch self-assigned this Jan 16, 2024
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation severity: low Does not significantly disrupt application functionality, or a workaround is available labels Jan 16, 2024
jeremystretch added a commit that referenced this issue Jan 16, 2024
jeremystretch added a commit that referenced this issue Jan 16, 2024
@ariandres
Copy link
Author

@jeremystretch Thank you very much, I think the commit does not take into account the last comment.
"Field Choice Set" has the same behavior with the "base_choices" field

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
2 participants