Skip to content

ValueError in web UI after REST API accepts invalid custom-field choice-set data #14755

@jeffgdotorg

Description

@jeffgdotorg

Deployment Type

Self-hosted

NetBox Version

v3.7.0

Python Version

3.10

Steps to Reproduce

  1. Start with a fresh NetBox 3.7.0 installation and database
  2. Post a custom-field choice-set whose choices are lists with just one element each (should be two elements each):
curl -H "Authorization: Token ${NETBOX_TOKEN}" \
  'http://192.168.64.3/api/extras/custom-field-choice-sets/' \
  -H 'accept: application/json'   -H 'Content-Type: application/json' \
  -d '[ { "name": "test1", "extra_choices": [ ["choice1"], ["choice2"] ] } ]'
  1. Log in to the web UI, navigate to Customization -> Custom Field Choices, and click on the test1 entry

Expected Behavior

The REST API should reject the POST data as invalid

AND/OR

The web UI should render a dialog showing that the choice set's choices have undefined labels

Observed Behavior

The REST API cheerfully creates the choice set with the choice labels undefined.

AND

The web UI displays an unstyled ValueError:

<class 'ValueError'>

Need 2 values to unpack in for loop; got 1. 

Python version: 3.10.12
NetBox version: 3.7.0
Plugins: None installed

This problem was originally reported by @jordanrvillarreal.

Metadata

Metadata

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