Script with MultiObjectVar throws TypeError if no 'data' is given and a null_option is used #6444

Closed
opened 2025-12-29 19:40:47 +01:00 by adam · 0 comments
Owner

Originally created by @PieterL75 on GitHub (May 4, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.2.1

Python version

3.9

Steps to Reproduce

Create a Script with MultiObjectVar field
Set null_option='Any'

    env_aggregate = MultiObjectVar(
        label = "Aggregate",
        model = Aggregate,
        null_option = 'All',
        required = False,

Run the script through the 'manage runscript' without providing any data.

Expected Behavior

Script runs fine

Observed Behavior

A TypeError is raised in DynamicModelMultipleChoiceField.clean()

f6402a8b62/netbox/utilities/forms/fields/dynamic.py (L125-L140)

The 'clean(self , value) gets the the 'value' parameter as 'None', if no data is passed to the script.
The 'in value' fails, as "argument of type 'NoneType' is not iterable"

Originally created by @PieterL75 on GitHub (May 4, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.2.1 ### Python version 3.9 ### Steps to Reproduce Create a Script with MultiObjectVar field Set null_option='Any' ``` env_aggregate = MultiObjectVar( label = "Aggregate", model = Aggregate, null_option = 'All', required = False, ``` Run the script through the 'manage runscript' without providing any data. ### Expected Behavior Script runs fine ### Observed Behavior A TypeError is raised in DynamicModelMultipleChoiceField.clean() https://github.com/netbox-community/netbox/blob/f6402a8b62498b4392e0809ba94e3db8c1bdc002/netbox/utilities/forms/fields/dynamic.py#L125-L140 The 'clean(self , value) gets the the 'value' parameter as 'None', if no data is passed to the script. The 'in value' fails, as "argument of type 'NoneType' is not iterable"
adam added the type: bugstatus: accepted labels 2025-12-29 19:40:47 +01:00
adam closed this issue 2025-12-29 19:40:47 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6444