Unable to query racks after migration #3247

Closed
opened 2025-12-29 18:27:04 +01:00 by adam · 2 comments
Owner

Originally created by @henyxia on GitHub (Jan 30, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.7.6
  • NetBox version: 2.7.3

Steps to Reproduce

  1. GET on /api/dcim/racks/8381/

What did you expect to happen?

Get the rack information

Observed Behavior

A 500 page with the error:

<class 'KeyError'>

'1000'

Additional information

After some digging, I think the issue comes from some racks where the outer_unit field was improperly migrated (going from 2.6.5 to 2.7.3).
In the database, I can see:

netbox=> select count(1), outer_unit from dcim_rack group by outer_unit;

 count | outer_unit
-------+------------
     9 | 1000
  4413 |
(2 rows)

Note

The issue might be related to https://github.com/netbox-community/netbox/issues/3967

Originally created by @henyxia on GitHub (Jan 30, 2020). Originally assigned to: @jeremystretch on GitHub. <!-- NOTE: This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.7.6 * NetBox version: 2.7.3 ### Steps to Reproduce 1. GET on /api/dcim/racks/8381/ ### What did you expect to happen? Get the rack information ### Observed Behavior A 500 page with the error: ``` <class 'KeyError'> '1000' ``` ### Additional information After some digging, I think the issue comes from some racks where the `outer_unit` field was improperly migrated (going from 2.6.5 to 2.7.3). In the database, I can see: ``` netbox=> select count(1), outer_unit from dcim_rack group by outer_unit; count | outer_unit -------+------------ 9 | 1000 4413 | (2 rows) ``` ### Note The issue might be related to https://github.com/netbox-community/netbox/issues/3967
adam added the type: bugstatus: accepted labels 2025-12-29 18:27:04 +01:00
adam closed this issue 2025-12-29 18:27:04 +01:00
Author
Owner

@DanSheps commented on GitHub (Jan 30, 2020):

I just checked, the migration is there so this will need a test migration from 2.6.x, I will check later this afternoon and let you know

@DanSheps commented on GitHub (Jan 30, 2020): I just checked, the migration is there so this will need a test migration from 2.6.x, I will check later this afternoon and let you know
Author
Owner

@jeremystretch commented on GitHub (Jan 30, 2020):

Yep, I see the issue. There's a typo in rack_outer_unit_to_slug(), similar to #4027. Will be fixed in the next release. Yet another example of something that should have been caught during the v2.7 beta, unfortunately.

As an immediate workaround, you can do this:

$ ./manage.py nbshell
### NetBox interactive shell (jstretch-workstation)
### Python 3.6.9 | Django 2.2.9 | NetBox 2.7.4-dev
### lsmodels() will show available models. Use help(<model>) for more info.
>>> Rack.objects.filter(outer_unit='1000').update(outer_unit='mm')
0
>>> Rack.objects.filter(outer_unit='2000').update(outer_unit='in')
0

(The number returned by either command indicates the number of rows that were updated.)

@jeremystretch commented on GitHub (Jan 30, 2020): Yep, I see the issue. There's a typo in `rack_outer_unit_to_slug()`, similar to #4027. Will be fixed in the next release. Yet another example of something that should have been caught during the v2.7 beta, unfortunately. As an immediate workaround, you can do this: ``` $ ./manage.py nbshell ### NetBox interactive shell (jstretch-workstation) ### Python 3.6.9 | Django 2.2.9 | NetBox 2.7.4-dev ### lsmodels() will show available models. Use help(<model>) for more info. >>> Rack.objects.filter(outer_unit='1000').update(outer_unit='mm') 0 >>> Rack.objects.filter(outer_unit='2000').update(outer_unit='in') 0 ``` (The number returned by either command indicates the number of rows that were updated.)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3247