Row 1 rack: Object not found. during device bulk import #4520

Closed
opened 2025-12-29 18:36:55 +01:00 by adam · 5 comments
Owner

Originally created by @goetzk on GitHub (Feb 2, 2021).

Hi @jeremystretch ,

I'm hoping to follow up https://github.com/netbox-community/netbox/issues/5238 as I have the same issue.

Environment

Python version: 3.8.5
NetBox version: 2.10.3

Steps to Reproduce

  1. Create DC0 under datacenters then create rack b06 in DC0
  2. Create 'Device role' Infrastructure
  3. Create 'Manufacturer' DELL
  4. Create 'Device Type' C6145
  5. Visit http://ipam/dcim/devices/import/
  6. Paste in the following lines
name,device_role,manufacturer,device_type,status,site,asset_tag,rack,position,comments
boohost,Infrastructure,DELL,C6145,active,DC0,4Kxxxxx,b06,22,

Expected Behavior

A new device created named boohost with an asset tag 4kxxxxx in RU22 of rack b06 in DC0.

Observed Behavior

The following error:

Row 1 rack: Object not found.
Row 1 position: Cannot select a rack position without assigning a rack.

I inserted the following debug statement and turned on logging for netbox.views at debug level.

diff --git a/netbox/netbox/views/generic.py b/netbox/netbox/views/generic.py
index bd21d469..856930ab 100644
--- a/netbox/netbox/views/generic.py
+++ b/netbox/netbox/views/generic.py
@@ -678,6 +678,7 @@ class BulkImportView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View):
                             obj = self._save_obj(obj_form, request)
                             new_objs.append(obj)
                         else:
+                            logger.log(obj_form.__dict__)
                             for field, err in obj_form.errors.items():
                                 form.add_error('csv', "Row {} {}: {}".format(row, field, err[0]))
                             raise ValidationError("")

That returned

{'obj_type': <ContentType: dcim | device>, 'custom_fields': ['cf_BGP_ASN'], 'instance': <Device: boohost>, '_validate_unique': True, 'is_bound': True, 'data': {'name': 'boohost', 'device_role': 'Infrastructure', 'manufacturer': 'DELL', 'device_type': 'C6145', 'status': 'active', 'site': 'DC0', 'asset_tag': '4Kxxxxx', 'rack': 'b06', 'position': '22', 'comments': ''}, 'files': <MultiValueDict: {}>, 'auto_id': 'id_%s', 'initial': {}, 'error_class': <class 'django.forms.utils.ErrorList'>, 'label_suffix': ':', 'empty_permitted': False, '_errors': {'rack': ['Object not found.'], 'position': ['Cannot select a rack position without assigning a rack.']}, 'fields': {'name': <django.forms.fields.CharField object at 0x7f4e777c1d00>, 'device_role': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777c1d90>, 'tenant': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777c1ca0>, 'manufacturer': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777c1eb0>, 'device_type': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777ce220>, 'platform': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777ce3d0>, 'serial': <django.forms.fields.CharField object at 0x7f4e777ce580>, 'asset_tag': <django.forms.fields.CharField object at 0x7f4e777ce370>, 'status': <utilities.forms.fields.CSVChoiceField object at 0x7f4e777ce6d0>, 'site': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777ce760>, 'rack_group': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777ce880>, 'rack': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777cea30>, 'position': <django.forms.fields.IntegerField object at 0x7f4e777cebe0>, 'face': <utilities.forms.fields.CSVChoiceField object at 0x7f4e777ceb80>, 'cluster': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777ced90>, 'comments': <django.forms.fields.CharField object at 0x7f4e777ceeb0>, 'cf_BGP_ASN': <django.forms.fields.CharField object at 0x7f4e777d5250>}, '_bound_fields_cache': {'status': <django.forms.boundfield.BoundField object at 0x7f4e777c1580>}, 'renderer': <django.forms.renderers.DjangoTemplates object at 0x7f4e77d04d30>, 'cleaned_data': {'name': 'boohost', 'device_role': <DeviceRole: Infrastructure>, 'tenant': None, 'manufacturer': <Manufacturer: DELL>, 'device_type': <DeviceType: C6145>, 'platform': None, 'serial': '', 'asset_tag': '4Kxxxxx', 'status': 'active', 'site': <Site: DC0>, 'rack_group': None, 'face': '', 'cluster': None, 'comments': '', 'cf_BGP_ASN': ''}}

I can say that rack definitely exists, and is at site DC0

>>> racks.Rack.objects.get(name='b06')
<Rack: b06>
>>> racks.Rack.objects.get(name='b06').status
'active'
>>> racks.Rack.objects.get(name='b06').site
<Site: DC0>
>>> racks.Rack.objects.get(name='b06').site.status
'active'

Note: I pruned out errors like this from the above output to improve readability.

/opt/netbox/venv/lib/python3.8/site-packages/cacheops/redis.py:19: RuntimeWarning: The cacheops cache is unreachable! Error: Client sent AUTH, but no password is set
  warnings.warn("The cacheops cache is unreachable! Error: %s" % e, RuntimeWarning)

Hopefully the above points to an error (user or system) which we can track down.
thanks
Karl.

Originally created by @goetzk on GitHub (Feb 2, 2021). Hi @jeremystretch , I'm hoping to follow up https://github.com/netbox-community/netbox/issues/5238 as I have the same issue. ### Environment Python version: 3.8.5 NetBox version: 2.10.3 ### Steps to Reproduce 1. Create DC0 under datacenters then create rack b06 in DC0 2. Create 'Device role' Infrastructure 3. Create 'Manufacturer' DELL 4. Create 'Device Type' C6145 5. Visit http://ipam/dcim/devices/import/ 6. Paste in the following lines ``` name,device_role,manufacturer,device_type,status,site,asset_tag,rack,position,comments boohost,Infrastructure,DELL,C6145,active,DC0,4Kxxxxx,b06,22, ``` ### Expected Behavior A new device created named boohost with an asset tag 4kxxxxx in RU22 of rack b06 in DC0. ### Observed Behavior The following error: ``` Row 1 rack: Object not found. Row 1 position: Cannot select a rack position without assigning a rack. ``` I inserted the following debug statement and turned on logging for netbox.views at debug level. ``` diff --git a/netbox/netbox/views/generic.py b/netbox/netbox/views/generic.py index bd21d469..856930ab 100644 --- a/netbox/netbox/views/generic.py +++ b/netbox/netbox/views/generic.py @@ -678,6 +678,7 @@ class BulkImportView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View): obj = self._save_obj(obj_form, request) new_objs.append(obj) else: + logger.log(obj_form.__dict__) for field, err in obj_form.errors.items(): form.add_error('csv', "Row {} {}: {}".format(row, field, err[0])) raise ValidationError("") ``` That returned ``` {'obj_type': <ContentType: dcim | device>, 'custom_fields': ['cf_BGP_ASN'], 'instance': <Device: boohost>, '_validate_unique': True, 'is_bound': True, 'data': {'name': 'boohost', 'device_role': 'Infrastructure', 'manufacturer': 'DELL', 'device_type': 'C6145', 'status': 'active', 'site': 'DC0', 'asset_tag': '4Kxxxxx', 'rack': 'b06', 'position': '22', 'comments': ''}, 'files': <MultiValueDict: {}>, 'auto_id': 'id_%s', 'initial': {}, 'error_class': <class 'django.forms.utils.ErrorList'>, 'label_suffix': ':', 'empty_permitted': False, '_errors': {'rack': ['Object not found.'], 'position': ['Cannot select a rack position without assigning a rack.']}, 'fields': {'name': <django.forms.fields.CharField object at 0x7f4e777c1d00>, 'device_role': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777c1d90>, 'tenant': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777c1ca0>, 'manufacturer': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777c1eb0>, 'device_type': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777ce220>, 'platform': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777ce3d0>, 'serial': <django.forms.fields.CharField object at 0x7f4e777ce580>, 'asset_tag': <django.forms.fields.CharField object at 0x7f4e777ce370>, 'status': <utilities.forms.fields.CSVChoiceField object at 0x7f4e777ce6d0>, 'site': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777ce760>, 'rack_group': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777ce880>, 'rack': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777cea30>, 'position': <django.forms.fields.IntegerField object at 0x7f4e777cebe0>, 'face': <utilities.forms.fields.CSVChoiceField object at 0x7f4e777ceb80>, 'cluster': <utilities.forms.fields.CSVModelChoiceField object at 0x7f4e777ced90>, 'comments': <django.forms.fields.CharField object at 0x7f4e777ceeb0>, 'cf_BGP_ASN': <django.forms.fields.CharField object at 0x7f4e777d5250>}, '_bound_fields_cache': {'status': <django.forms.boundfield.BoundField object at 0x7f4e777c1580>}, 'renderer': <django.forms.renderers.DjangoTemplates object at 0x7f4e77d04d30>, 'cleaned_data': {'name': 'boohost', 'device_role': <DeviceRole: Infrastructure>, 'tenant': None, 'manufacturer': <Manufacturer: DELL>, 'device_type': <DeviceType: C6145>, 'platform': None, 'serial': '', 'asset_tag': '4Kxxxxx', 'status': 'active', 'site': <Site: DC0>, 'rack_group': None, 'face': '', 'cluster': None, 'comments': '', 'cf_BGP_ASN': ''}} ``` I can say that rack definitely exists, and is at site DC0 ``` >>> racks.Rack.objects.get(name='b06') <Rack: b06> >>> racks.Rack.objects.get(name='b06').status 'active' >>> racks.Rack.objects.get(name='b06').site <Site: DC0> >>> racks.Rack.objects.get(name='b06').site.status 'active' ``` Note: I pruned out errors like this from the above output to improve readability. ``` /opt/netbox/venv/lib/python3.8/site-packages/cacheops/redis.py:19: RuntimeWarning: The cacheops cache is unreachable! Error: Client sent AUTH, but no password is set warnings.warn("The cacheops cache is unreachable! Error: %s" % e, RuntimeWarning) ``` Hopefully the above points to an error (user or system) which we can track down. thanks Karl.
adam closed this issue 2025-12-29 18:36:55 +01:00
Author
Owner

@jeremystretch commented on GitHub (Feb 2, 2021):

It looks you're missing the face field for import. When specifying a value for the rack face, I was able to import a device successfully following the steps you provided. Please try adding the face field and re-testing.

@jeremystretch commented on GitHub (Feb 2, 2021): It looks you're missing the `face` field for import. When specifying a value for the rack face, I was able to import a device successfully following the steps you provided. Please try adding the `face` field and re-testing.
Author
Owner

@goetzk commented on GitHub (Feb 2, 2021):

Unfortunately I see more or less the same result , though this time the second entry is about 'face' not 'position'.

name,device_role,manufacturer,device_type,status,site,asset_tag,rack,position,comments,face
boohost,Infrastructure,DELL,C6145,active,DC0,4Kxxxxx,b06,22,,front

with error

Enter the list of column headers followed by one line per record to be imported, using commas to separate values. Multi-line data and values containing commas may be wrapped in double quotes.

    Row 1 rack: Object not found.
    Row 1 face: Cannot select a rack face without assigning a rack.
@goetzk commented on GitHub (Feb 2, 2021): Unfortunately I see more or less the same result , though this time the second entry is about 'face' not 'position'. ``` name,device_role,manufacturer,device_type,status,site,asset_tag,rack,position,comments,face boohost,Infrastructure,DELL,C6145,active,DC0,4Kxxxxx,b06,22,,front ``` with error ``` Enter the list of column headers followed by one line per record to be imported, using commas to separate values. Multi-line data and values containing commas may be wrapped in double quotes. Row 1 rack: Object not found. Row 1 face: Cannot select a rack face without assigning a rack. ```
Author
Owner

@goetzk commented on GitHub (Feb 4, 2021):

The below DOES work:

name,device_role,manufacturer,device_type,status,site,asset_tag,rack,position,comments,face,rack_group
boohost,Infrastructure,DELL,C6145,active,DC0,4Kxxxxx,b06,22,,front,Row B

I haven't tried to dig in to the validation but it seems there is an implicit requirement to add all rack related fields if rack is added.

@goetzk commented on GitHub (Feb 4, 2021): The below DOES work: ``` name,device_role,manufacturer,device_type,status,site,asset_tag,rack,position,comments,face,rack_group boohost,Infrastructure,DELL,C6145,active,DC0,4Kxxxxx,b06,22,,front,Row B ``` I haven't tried to dig in to the validation but it seems there is an implicit requirement to add all rack related fields if rack is added.
Author
Owner

@jeremystretch commented on GitHub (Mar 17, 2021):

As noted above, I was not able to reproduce this bug. It's likely some other piece of data is missing or incorrect. Please consider opening a GitHub discussion for assistance.

@jeremystretch commented on GitHub (Mar 17, 2021): As noted above, I was not able to reproduce this bug. It's likely some other piece of data is missing or incorrect. Please consider opening a GitHub discussion for assistance.
Author
Owner

@martinum4 commented on GitHub (May 5, 2021):

I had the same error, probably from using the same location-name multiple times.

For me it helped to add location.id with the corresponding location ID where the Rack is located.

@martinum4 commented on GitHub (May 5, 2021): I had the same error, probably from using the same location-name multiple times. For me it helped to add `location.id` with the corresponding location ID where the Rack is located.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4520