Changing CSV field accessor does not work with auto-detect format #7610

Closed
opened 2025-12-29 20:26:02 +01:00 by adam · 1 comment
Owner

Originally created by @sleepinggenius2 on GitHub (Feb 6, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.4.4

Python version

3.8

Steps to Reproduce

  1. Create Region with name = "Foo" and slug = "foo"
  2. Navigate to Site Bulk Import
  3. Populate Data with:
name,slug,status,region.slug
Bar,bar,active,foo
  1. Leave Format as Auto-detect
  2. Click Submit button

Expected Behavior

Site is created successfully under the Foo region.

Observed Behavior

A toast error message saying Record 1 region: Object not found: foo appears.

I believe this is due to this if statement being False, so the correct headers are never set:
93ac0b77c9/netbox/netbox/views/generic/bulk_views.py (L387-L388)

When the format is auto-detected here:

93685d92a4/netbox/utilities/forms/forms.py (L187-L191)

The value for form.cleaned_data['format'] is never updated to reflect the auto-detected format, so it is still ImportFormatChoices.AUTO when checked in the view.

Originally created by @sleepinggenius2 on GitHub (Feb 6, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.4.4 ### Python version 3.8 ### Steps to Reproduce 1. Create *Region* with *name* = "Foo" and *slug* = "foo" 2. Navigate to *Site Bulk Import* 3. Populate *Data* with: ``` name,slug,status,region.slug Bar,bar,active,foo ``` 4. Leave *Format* as *Auto-detect* 5. Click *Submit* button ### Expected Behavior Site is created successfully under the *Foo* region. ### Observed Behavior A toast error message saying `Record 1 region: Object not found: foo` appears. I believe this is due to this if statement being False, so the correct headers are never set: https://github.com/netbox-community/netbox/blob/93ac0b77c94b2e761176d07c92ba0fa699ba76e3/netbox/netbox/views/generic/bulk_views.py#L387-L388 When the format is auto-detected here: https://github.com/netbox-community/netbox/blob/93685d92a40de88688b24ab7150d549275b236e9/netbox/utilities/forms/forms.py#L187-L191 The value for `form.cleaned_data['format']` is never updated to reflect the auto-detected format, so it is still `ImportFormatChoices.AUTO` when checked in the view.
adam added the type: bugstatus: accepted labels 2025-12-29 20:26:02 +01:00
adam closed this issue 2025-12-29 20:26:02 +01:00
Author
Owner

@jeremystretch commented on GitHub (Feb 7, 2023):

Thanks for tracking this down @sleepinggenius2!

@jeremystretch commented on GitHub (Feb 7, 2023): Thanks for tracking this down @sleepinggenius2!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7610