Skip to content

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

@sleepinggenius2

Description

@sleepinggenius2

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:

if form.cleaned_data['format'] == ImportFormatChoices.CSV:
model_form_kwargs['headers'] = form._csv_headers

When the format is auto-detected here:

# Determine the data format
if self.cleaned_data['format'] == ImportFormatChoices.AUTO:
format = self._detect_format(data)
else:
format = self.cleaned_data['format']

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.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions