KeyError: 'csv' on device import #5174

Closed
opened 2025-12-29 19:25:06 +01:00 by adam · 2 comments
Owner

Originally created by @pobk on GitHub (Aug 11, 2021).

NetBox version

v2.11.10

Python version

3.8

Steps to Reproduce

  1. Create Roles, manufacturers, type and sites and tenant
  2. Open device import view. paste the following:
name,status,tenant,role,manufacturer,type,site
idrac-hostname-01,Active,Some Team,Lights out management,Dell,iDRAC,Equinix LD5
  1. Submit pasted content

This occurs if using the pasted content or uploaded file. I have tested importing other objects and this works with something simple such as tags, for example.

Expected Behavior

Devices should be correctly imported

Observed Behavior

The following exception is raised:

Internal Server Error: /dcim/devices/import/
Traceback (most recent call last):
  File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 93, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic.py", line 713, in post
    if form.is_valid():
  File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/forms/forms.py", line 175, in is_valid
    return self.is_bound and not self.errors
  File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/forms/forms.py", line 170, in errors
    self.full_clean()
  File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/forms/forms.py", line 373, in full_clean
    self._clean_form()
  File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/forms/forms.py", line 400, in _clean_form
    cleaned_data = self.clean()
  File "/opt/netbox/netbox/netbox/views/generic.py", line 678, in clean
    csv_rows = self.cleaned_data['csv'][1]
KeyError: 'csv'```

Originally created by @pobk on GitHub (Aug 11, 2021). ### NetBox version v2.11.10 ### Python version 3.8 ### Steps to Reproduce 1. Create Roles, manufacturers, type and sites and tenant 2. Open device import view. paste the following: ``` name,status,tenant,role,manufacturer,type,site idrac-hostname-01,Active,Some Team,Lights out management,Dell,iDRAC,Equinix LD5 ``` 2. Submit pasted content This occurs if using the pasted content or uploaded file. I have tested importing other objects and this works with something simple such as tags, for example. ### Expected Behavior Devices should be correctly imported ### Observed Behavior The following exception is raised: ``` Internal Server Error: /dcim/devices/import/ Traceback (most recent call last): File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 93, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 98, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic.py", line 713, in post if form.is_valid(): File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/forms/forms.py", line 175, in is_valid return self.is_bound and not self.errors File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/forms/forms.py", line 170, in errors self.full_clean() File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/forms/forms.py", line 373, in full_clean self._clean_form() File "/opt/netbox-2.11.10/venv/lib/python3.8/site-packages/django/forms/forms.py", line 400, in _clean_form cleaned_data = self.clean() File "/opt/netbox/netbox/netbox/views/generic.py", line 678, in clean csv_rows = self.cleaned_data['csv'][1] KeyError: 'csv'```
adam added the type: bug label 2025-12-29 19:25:06 +01:00
adam closed this issue 2025-12-29 19:25:06 +01:00
Author
Owner

@pobk commented on GitHub (Aug 11, 2021):

Oh bugger... ignore me...

I made the mistake of using the exported file thinking I could just use the same headings to subsequently import new devices.

However, that's a bit of a bug. I'll submit something differently.

@pobk commented on GitHub (Aug 11, 2021): Oh bugger... ignore me... I made the mistake of using the exported file thinking I could just use the same headings to subsequently import new devices. However, that's a bit of a bug. I'll submit something differently.
Author
Owner

@jeremystretch commented on GitHub (Aug 11, 2021):

FYI the KeyError exception has been fixed under #6910 for the upcoming release.

@jeremystretch commented on GitHub (Aug 11, 2021): FYI the KeyError exception has been fixed under #6910 for the upcoming release.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5174