Crash when device name is a number greater thant an integer. #584

Closed
opened 2025-12-29 16:23:30 +01:00 by adam · 1 comment
Owner

Originally created by @Mmoi-Fr on GitHub (Dec 19, 2016).

Hi,

I got an error after I added the device named "N010025001001".

When I try to see the devices from the city where that device is, I get a "Django.utils" error saying that the name exceed the integer limits.

The only way to correct this was to delete the device in postgres itself...

Could you check it out?

Thx

Originally created by @Mmoi-Fr on GitHub (Dec 19, 2016). Hi, I got an error after I added the device named "N010025001001". When I try to see the devices from the city where that device is, I get a "Django.utils" error saying that the name exceed the integer limits. The only way to correct this was to delete the device in postgres itself... Could you check it out? Thx
adam added the type: bug label 2025-12-29 16:23:30 +01:00
adam closed this issue 2025-12-29 16:23:31 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 19, 2016):

This was due to the way we implement natural ordering for device names. This ensures that, for example, a device named router30 shows up between router1 and router100. We do this by casting the trailing numeric portion as an integer and sorting on it separately.

In this case, NetBox was attempting to cast the number 10025001001 as an integer, which is too big to fit the type (the maximum value of a signed four-byte integer is 2147483647). I've adjusted the regex to match only up to nine digits, which ensures that the captured value can be converted to an integer. This approach can likely be improved, but be should be sufficient in the short term.

@jeremystretch commented on GitHub (Dec 19, 2016): This was due to the way we implement natural ordering for device names. This ensures that, for example, a device named router30 shows up between router1 and router100. We do this by casting the trailing numeric portion as an integer and sorting on it separately. In this case, NetBox was attempting to cast the number 10025001001 as an integer, which is too big to fit the type (the maximum value of a signed four-byte integer is 2147483647). I've adjusted the regex to match only up to nine digits, which ensures that the captured value can be converted to an integer. This approach can likely be improved, but be should be sufficient in the short term.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#584