API Exception with invalid choice value #2807

Closed
opened 2025-12-29 18:22:21 +01:00 by adam · 0 comments
Owner

Originally created by @candlerb on GitHub (Aug 15, 2019).

Environment

  • Python version: 3.5.2
  • NetBox version: 2.6.2

Steps to Reproduce

Pass a list instead of an integer for interface type when creating an interface, e.g. [32767] instead of 32767

See forum thread

Expected Behavior

Value to be rejected by API as invalid

Observed Behavior

Exception with backtrace - makes it very hard to know where the data error was.

This is because a list is not hashable, and so the test if data not in self._choices: raises an exception. Code link

Originally created by @candlerb on GitHub (Aug 15, 2019). ### Environment * Python version: 3.5.2 * NetBox version: 2.6.2 ### Steps to Reproduce Pass a list instead of an integer for interface type when creating an interface, e.g. `[32767]` instead of `32767` See [forum thread](https://groups.google.com/forum/#!topic/netbox-discuss/H7xIrwVnOSM) ### Expected Behavior Value to be rejected by API as invalid ### Observed Behavior Exception with backtrace - makes it very hard to know where the data error was. This is because a list is not hashable, and so the test `if data not in self._choices:` raises an exception. [Code link](https://github.com/netbox-community/netbox/blob/develop/netbox/utilities/api.py#L104)
adam added the type: bugstatus: accepted labels 2025-12-29 18:22:21 +01:00
adam closed this issue 2025-12-29 18:22:21 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2807