[PR #7732] [CLOSED] Change big auto int to string in the API #13277

Closed
opened 2025-12-29 22:26:29 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/7732
Author: @TheEnbyperor
Created: 11/3/2021
Status: Closed

Base: developHead: id-fix


📝 Commits (1)

  • a599f8d change big auto to string in the API

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 netbox/netbox/api/serializers.py (+1 -1)

📄 Description

When dealing with large row IDs such as those generated by cockroachDB, the JS floating point implementation can alter IDs returned from the API when parsing JSON. This results in nonexistent rows being queried.

As can be seen below the ID in JSON and the ID in JS do not match up.

let data = JSON.parse('{"count":1,"next":null,"previous":null,"results":[{"id":707372639259361282,"url":"http://nb.as207960.net/api/ipam/rirs/707372639259361282/","display":"RIPE","name":"RIPE","slug":"ripe","aggregate_count":1}]}');
undefined
// data.results[0].id
707372639259361300

This PR changes the return type of the API from an int to a string, so as to avoid this error.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/7732 **Author:** [@TheEnbyperor](https://github.com/TheEnbyperor) **Created:** 11/3/2021 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `id-fix` --- ### 📝 Commits (1) - [`a599f8d`](https://github.com/netbox-community/netbox/commit/a599f8d597c5dd20d878f3acf9feefaff3cc2bca) change big auto to string in the API ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `netbox/netbox/api/serializers.py` (+1 -1) </details> ### 📄 Description When dealing with large row IDs such as those generated by cockroachDB, the JS floating point implementation can alter IDs returned from the API when parsing JSON. This results in nonexistent rows being queried. As can be seen below the ID in JSON and the ID in JS do not match up. ```javascript let data = JSON.parse('{"count":1,"next":null,"previous":null,"results":[{"id":707372639259361282,"url":"http://nb.as207960.net/api/ipam/rirs/707372639259361282/","display":"RIPE","name":"RIPE","slug":"ripe","aggregate_count":1}]}'); undefined // data.results[0].id 707372639259361300 ``` This PR changes the return type of the API from an int to a string, so as to avoid this error. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:26:29 +01:00
adam closed this issue 2025-12-29 22:26:30 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13277