CustomFieldColumn doesn't render MultiSelect integers #7161

Closed
opened 2025-12-29 20:19:56 +01:00 by adam · 3 comments
Owner

Originally created by @steffenschumacher on GitHub (Oct 26, 2022).

NetBox version

v3.3.5

Python version

3.10

Steps to Reproduce

  1. Add custom field to eg. ipam::role, which are MultiSelect, default to null and valid values are integers: 0,1,2,3,4,5,6
  2. Create a new ipam::role, which has the custom field set to eg. 1,2,3
  3. Display a list of ipam::roles
  4. modify which columns are displayed, and include the new custom field

Expected Behavior

The column for the new custom field should display eg. 1,2,3 for the created role

Observed Behavior

you will see this error in the browser: sequence item 0: expected str instance, int found, and this is logged:

File "/opt/netbox/netbox/netbox/tables/columns.py", line 442, in render
return ', '.join(v for v in value)
TypeError: sequence item 0: expected str instance, int found

And the issue seems to be a missing str() conversion in:

return ', '.join(v for v in value) => return ', '.join(**str(v)** for v in value)
Originally created by @steffenschumacher on GitHub (Oct 26, 2022). ### NetBox version v3.3.5 ### Python version 3.10 ### Steps to Reproduce 1. Add custom field to eg. ipam::role, which are MultiSelect, default to null and valid values are integers: 0,1,2,3,4,5,6 2. Create a new ipam::role, which has the custom field set to eg. 1,2,3 3. Display a list of ipam::roles 4. modify which columns are displayed, and include the new custom field ### Expected Behavior The column for the new custom field should display eg. 1,2,3 for the created role ### Observed Behavior you will see this error in the browser: sequence item 0: expected str instance, int found, and this is logged: <cut> File "/opt/netbox/netbox/netbox/tables/columns.py", line 442, in render return ', '.join(v for v in value) TypeError: sequence item 0: expected str instance, int found And the issue seems to be a missing str() conversion in: ```python return ', '.join(v for v in value) => return ', '.join(**str(v)** for v in value) ```
adam added the type: bugstatus: revisions needed labels 2025-12-29 20:19:56 +01:00
adam closed this issue 2025-12-29 20:19:56 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 26, 2022):

I'm not able to reproduce this. The field is displayed as expected. Note that the field values are always stored as strings when input via the UI or API. Presumably you've injected integer values where they should be strings.

@jeremystretch commented on GitHub (Oct 26, 2022): I'm not able to reproduce this. The field is displayed as expected. Note that the field values are always stored as strings when input via the UI or API. Presumably you've injected integer values where they should be strings.
Author
Owner

@steffenschumacher commented on GitHub (Oct 28, 2022):

Sorry - you're correct - these values were inserted via the initialisers previously part of netbox-docker - now a separate plugin - I've fixed it to strings and it all works out now..
I don't think it matters much if its strings or not, and my code will be able to cast the strings back to integers, but are there any good reasons for why integers aren't allowed?

@steffenschumacher commented on GitHub (Oct 28, 2022): Sorry - you're correct - these values were inserted via the initialisers previously part of netbox-docker - now a separate plugin - I've fixed it to strings and it all works out now.. I don't think it matters much if its strings or not, and my code will be able to cast the strings back to integers, but are there any good reasons for why integers aren't allowed?
Author
Owner

@jeremystretch commented on GitHub (Oct 31, 2022):

are there any good reasons for why integers aren't allowed?

The choice values are stored as strings for consistency. For example, you might start with choices 1, 2, and 3, and assume that these should be stored as integers. But what happens when someone adds choice "1B"? You now have a mix of integers and strings. We stick with strings for all values to avoid confusion.

@jeremystretch commented on GitHub (Oct 31, 2022): > are there any good reasons for why integers aren't allowed? The choice values are stored as strings for consistency. For example, you might start with choices 1, 2, and 3, and assume that these should be stored as integers. But what happens when someone adds choice "1B"? You now have a mix of integers and strings. We stick with strings for all values to avoid confusion.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7161