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

Closed
opened 2025-12-29 20:45:03 +01:00 by adam · 2 comments
Owner

Originally created by @jeffgdotorg on GitHub (Jan 9, 2024).

Originally assigned to: @Julio-Oliveira-Encora on GitHub.

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.

Originally created by @jeffgdotorg on GitHub (Jan 9, 2024). Originally assigned to: @Julio-Oliveira-Encora on GitHub. ### 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"] ] } ]' ``` 3. 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.
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 20:45:03 +01:00
adam closed this issue 2025-12-29 20:45:04 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 16, 2024):

@Julio-Oliveira-Encora I see that you've submitted a PR for this. If you'd like to own this issue, please comment here so that it can be assigned to you. Thanks!

@jeremystretch commented on GitHub (Jan 16, 2024): @Julio-Oliveira-Encora I see that you've submitted a PR for this. If you'd like to own this issue, please comment here so that it can be assigned to you. Thanks!
Author
Owner

@Julio-Oliveira-Encora commented on GitHub (Jan 16, 2024):

@jeremystretch

Please, fell free to assigned it to me.

@Julio-Oliveira-Encora commented on GitHub (Jan 16, 2024): @jeremystretch Please, fell free to assigned it to me.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9070