API endpoint /api/dcim/interfaces returns non-unique list. #2454

Closed
opened 2025-12-29 18:18:58 +01:00 by adam · 6 comments
Owner

Originally created by @pm17788 on GitHub (Mar 11, 2019).

Environment

  • Python version: 3.5.2
  • NetBox version: 2.5.5

Steps to Reproduce

  1. Use API to do a lot of interface creation/deletion. (We have ~90000 interfaces)
  2. Use curl to iterate over all results from /api/dcim/interfaces API endpoint
  3. Use jq to parse the results, pass that to sort -u | wc -l
  4. Use manage.py nbshell CLI interface to write out all interfaces' numeric ID and CSV export
  5. Compare the datasets.

Expected Behavior

Datasets derived from manage.py nbshell and API gathers should be identical. API should never return duplicates.

Observed Behavior

This is reminiscent of the behaviour I observed in #2415.

  1. API reports that the count should be 89575. Of those, 89307 are unique. 268 entries are missing.
  2. Comparing the dataset from API with the dataset from manage.py nbshell, there are discrepancies. The missing 268 are shown.

Shell script attached below helps run all of those:

  1. bash duplicate_interfaces_bug.sh get_api_data
  2. bash duplicate_interfaces_bug.sh jq
  3. bash duplicate_interfaces_bug.sh nbshell_cmds
  4. bash duplicate_interfaces_bug.sh compare_nbshell_to_API

duplicate_interfaces_bug.txt

Originally created by @pm17788 on GitHub (Mar 11, 2019). ### Environment * Python version: 3.5.2 * NetBox version: 2.5.5 ### Steps to Reproduce 1. Use API to do a lot of interface creation/deletion. (We have ~90000 interfaces) 1. Use curl to iterate over all results from `/api/dcim/interfaces` API endpoint 1. Use `jq` to parse the results, pass that to `sort -u | wc -l` 1. Use `manage.py nbshell` CLI interface to write out all interfaces' numeric ID and CSV export 1. Compare the datasets. ### Expected Behavior Datasets derived from `manage.py nbshell` and API gathers should be identical. API should never return duplicates. ### Observed Behavior #### This is reminiscent of the behaviour I observed in #2415. 1. API reports that the count should be 89575. Of those, 89307 are unique. 268 entries are missing. 1. Comparing the dataset from API with the dataset from `manage.py nbshell`, there *are* discrepancies. The missing 268 are shown. Shell script attached below helps run all of those: 1. `bash duplicate_interfaces_bug.sh get_api_data` 1. `bash duplicate_interfaces_bug.sh jq` 1. `bash duplicate_interfaces_bug.sh nbshell_cmds` 1. `bash duplicate_interfaces_bug.sh compare_nbshell_to_API` [duplicate_interfaces_bug.txt](https://github.com/digitalocean/netbox/files/2954153/duplicate_interfaces_bug.txt)
adam closed this issue 2025-12-29 18:18:59 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 12, 2019):

This looks like #2938, which was fixed in v2.5.8 (released yesterday). Please upgrade and see if that resolves the issue. If not, please request to have this reopened.

@jeremystretch commented on GitHub (Mar 12, 2019): This looks like #2938, which was fixed in v2.5.8 (released yesterday). Please upgrade and see if that resolves the issue. If not, please request to have this reopened.
Author
Owner

@pm17788 commented on GitHub (Mar 12, 2019):

@jeremystretch:
Sadly, 2.5.8 seems to be exhibiting this behaviour, too.
Please re-open this bug.
I re-did my DEV instance yesterday by restoring my PROD (which is currently at 2.5.5), then upgraded DEV from 2.5.5 to 2.5.8, and re-ran my process against the DEV instance. There were, sadly, duplicates detected.

root@netbox-dev-1:/opt/netbox/netbox# python3 ./manage.py nbshell
### NetBox interactive shell (netbox-dev-1)
### Python 3.5.2 | Django 2.1.7 | NetBox 2.5.8
### lsmodels() will show available models. Use help(<model>) for more info.
@pm17788 commented on GitHub (Mar 12, 2019): @jeremystretch: Sadly, 2.5.8 seems to be exhibiting this behaviour, too. Please re-open this bug. I re-did my DEV instance yesterday by restoring my PROD (which is currently at 2.5.5), then upgraded DEV from 2.5.5 to 2.5.8, and re-ran my process against the DEV instance. There were, sadly, duplicates detected. ``` root@netbox-dev-1:/opt/netbox/netbox# python3 ./manage.py nbshell ### NetBox interactive shell (netbox-dev-1) ### Python 3.5.2 | Django 2.1.7 | NetBox 2.5.8 ### lsmodels() will show available models. Use help(<model>) for more info. ```
Author
Owner

@pm17788 commented on GitHub (Mar 21, 2019):

@jeremystretch: Sorry to be a pest, but this is kicking our butts a bit. Please re-open the issue?

@pm17788 commented on GitHub (Mar 21, 2019): @jeremystretch: Sorry to be a pest, but this is kicking our butts a bit. Please re-open the issue?
Author
Owner

@jeremystretch commented on GitHub (Mar 21, 2019):

Should be covered by #2207

@jeremystretch commented on GitHub (Mar 21, 2019): Should be covered by #2207
Author
Owner

@pm17788 commented on GitHub (Apr 1, 2019):

@jeremystretch: Sadly, does not appear to be the case.
Tested PR 2996 on my NetBox v 2.5.8 instance:

69         sql_col = '{}.name'.format(self.model._meta.db_table)
70         ordering = [
71             '_slot', '_subslot', '_position', '_subposition', '_type', '_id', '_channel', '_vc', 'name', 'pk'
72         ]
73 

Still the same issue with interfaces not being returned as a unique list.

@pm17788 commented on GitHub (Apr 1, 2019): @jeremystretch: Sadly, does not appear to be the case. Tested PR 2996 on my NetBox v 2.5.8 instance: ```python 69 sql_col = '{}.name'.format(self.model._meta.db_table) 70 ordering = [ 71 '_slot', '_subslot', '_position', '_subposition', '_type', '_id', '_channel', '_vc', 'name', 'pk' 72 ] 73 ``` Still the same issue with interfaces not being returned as a unique list.
Author
Owner

@pm17788 commented on GitHub (Apr 3, 2019):

Tested on a full 2.5.9, and that works. Probably something I messed up with my test or some such. Huzzah!

@pm17788 commented on GitHub (Apr 3, 2019): Tested on a full 2.5.9, and that works. Probably something I messed up with my test or some such. Huzzah!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2454