Netbox: Unable to query racks after migration

Created on 30 Jan 2020  路  2Comments  路  Source: netbox-community/netbox

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

accepted bug

Most helpful comment

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.)

All 2 comments

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

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.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hoalex picture hoalex  路  3Comments

VictorJ76 picture VictorJ76  路  3Comments

robbagithub picture robbagithub  路  3Comments

markve-sa picture markve-sa  路  4Comments

candlerb picture candlerb  路  3Comments