Interface 32767 'Other' Type API bug #3195

Closed
opened 2025-12-29 18:26:31 +01:00 by adam · 8 comments
Owner

Originally created by @darcynz on GitHub (Jan 21, 2020).

Originally assigned to: @jeremystretch on GitHub.

ment

  • Python version: 3.7
  • NetBox version: 2.7.1

Steps to Reproduce

  1. View '32767' Type (Other) interface via api eg:
    https://netbox/api/dcim/interfaces/11373/

View API data of the interface

Request Method: GET
http://***/api/dcim/interfaces/9016/
2.2.9
KeyError
'32767'
/opt/netbox/netbox/utilities/api.py in to_representation, line 86
/usr/local/bin/python
3.7.6
['/opt/netbox/netbox', '/usr/local/bin', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages']
Tue, 21 Jan 2020 16:06:34 +1300
Originally created by @darcynz on GitHub (Jan 21, 2020). Originally assigned to: @jeremystretch on GitHub. ment * Python version: 3.7 * NetBox version: 2.7.1 ### Steps to Reproduce 1. View '32767' Type (Other) interface via api eg: https://netbox/api/dcim/interfaces/11373/ <!-- What did you expect to happen? --> View API data of the interface <!-- What happened instead? --> Request Method: | GET -- | -- http://***/api/dcim/interfaces/9016/ 2.2.9 KeyError '32767' /opt/netbox/netbox/utilities/api.py in to_representation, line 86 /usr/local/bin/python 3.7.6 ['/opt/netbox/netbox', '/usr/local/bin', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages'] Tue, 21 Jan 2020 16:06:34 +1300
adam added the type: bugstatus: accepted labels 2025-12-29 18:26:31 +01:00
adam closed this issue 2025-12-29 18:26:31 +01:00
Author
Owner

@kobayashi commented on GitHub (Jan 21, 2020):

This issue has been closed as it does not conform to one of the provided templates as required by the contributing guide. If you'd like to request that your issue be re-opened, please first update the content so that it matches the appropriate template (this may require rewriting your issue entirely).

@kobayashi commented on GitHub (Jan 21, 2020): This issue has been closed as it does not conform to one of the [provided templates](https://github.com/digitalocean/netbox/issues/new/choose) as required by the [contributing guide](https://github.com/digitalocean/netbox/blob/master/CONTRIBUTING.md). If you'd like to request that your issue be re-opened, please first update the content so that it matches the appropriate template (this may require rewriting your issue entirely).
Author
Owner

@kobayashi commented on GitHub (Jan 21, 2020):

Sorry, I found this was discussed in mailing list.

@kobayashi commented on GitHub (Jan 21, 2020): Sorry, I found this was discussed in mailing list.
Author
Owner

@kobayashi commented on GitHub (Jan 21, 2020):

Could you let us know more specific steps to reproduce the issue like parameters of the interface? While I am trying api access to 'Other type' interface, cannot reproduce.

@kobayashi commented on GitHub (Jan 21, 2020): Could you let us know more specific steps to reproduce the issue like parameters of the interface? While I am trying api access to 'Other type' interface, cannot reproduce.
Author
Owner

@candlerb commented on GitHub (Jan 21, 2020):

I can reproduce this. On a system which has been updated from 2.6 to 2.7:

netbox=# select type,count(*) from dcim_interface group by type;
      type      | count
----------------+-------
 virtual        |    44
 lag            |     1
 100base-tx     |     1
 32767          |     2      <<<< NOTE
 ieee802.11g    |     1
 1000base-t     |    44
 ieee802.11n    |     3
 1000base-x-sfp |     3
(8 rows)

That value wasn't updated as part of the migration.

I note that TYPE_OTHER is missing from LEGACY_MAP here. I don't know if this mapping is used as part of the migration logic.

@candlerb commented on GitHub (Jan 21, 2020): I can reproduce this. On a system which has been updated from 2.6 to 2.7: ``` netbox=# select type,count(*) from dcim_interface group by type; type | count ----------------+------- virtual | 44 lag | 1 100base-tx | 1 32767 | 2 <<<< NOTE ieee802.11g | 1 1000base-t | 44 ieee802.11n | 3 1000base-x-sfp | 3 (8 rows) ``` That value wasn't updated as part of the migration. I note that `TYPE_OTHER` is missing from `LEGACY_MAP` [here](https://github.com/netbox-community/netbox/blob/develop/netbox/dcim/choices.py#L805). I don't know if this mapping is used as part of the migration logic.
Author
Owner

@candlerb commented on GitHub (Jan 21, 2020):

FYI: in the GUI at /dcim/interfaces/ or /dcim/interfaces/<N>/, the type just displays as "32767".

Checking in code: frontport and rearport never had the choice other, so should be unaffected.

For completeness: I also checked console and power ports in the database. These are showing empty string as the value for type. This doesn't cause a problem with the API, which returns null for the type, nor for the GUI, which allows the type to be unset (--------)

@candlerb commented on GitHub (Jan 21, 2020): FYI: in the GUI at `/dcim/interfaces/` or `/dcim/interfaces/<N>/`, the type just displays as "32767". Checking in code: frontport and rearport never had the choice `other`, so should be unaffected. For completeness: I also checked console and power ports in the database. These are showing empty string as the value for `type`. This doesn't cause a problem with the API, which returns `null` for the type, nor for the GUI, which allows the type to be unset (`--------`)
Author
Owner

@candlerb commented on GitHub (Jan 21, 2020):

Quick fix:

# sudo -u postgres psql netbox
netbox=# update dcim_interface set type='other' where type='32767';
netbox=# \q

(but this ought to go into a new migration)

@candlerb commented on GitHub (Jan 21, 2020): Quick fix: ``` # sudo -u postgres psql netbox netbox=# update dcim_interface set type='other' where type='32767'; netbox=# \q ``` (but this ought to go into a new migration)
Author
Owner

@candlerb commented on GitHub (Jan 21, 2020):

For reference, original report was here.

I wonder if it would also be worth making the line which raised the exception more robust, by changing self._choices[obj] to self._choices.get(obj) ?

@candlerb commented on GitHub (Jan 21, 2020): For reference, original report was [here](https://groups.google.com/d/msg/netbox-discuss/A4TAsOPPveE/vVVtRTQVDwAJ). I wonder if it would also be worth making the [line which raised the exception](https://github.com/netbox-community/netbox/blob/develop/netbox/utilities/api.py#L86) more robust, by changing `self._choices[obj]` to `self._choices.get(obj)` ?
Author
Owner

@jeremystretch commented on GitHub (Feb 7, 2020):

The patch for this did not include interface templates. Re-opening so it can be re-addressed in the next release.

@jeremystretch commented on GitHub (Feb 7, 2020): The patch for this did not include interface templates. Re-opening so it can be re-addressed in the next release.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3195