@@ -85,7 +85,7 @@ class Device(ObjectType):
8585 devStatus = String (description = "Online/Offline status" )
8686 devIsRandomMac = Int (description = "Calculated: Is MAC address randomized?" )
8787 devParentChildrenCount = Int (description = "Calculated: Number of children attached to this parent" )
88- devIpLong = Int (description = "Calculated: IP address in long format" )
88+ devIpLong = String (description = "Calculated: IP address in long format (returned as string to support the full unsigned 32-bit range) " )
8989 devFilterStatus = String (description = "Calculated: Device status for UI filtering" )
9090 devFQDN = String (description = "Fully Qualified Domain Name" )
9191 devParentRelType = String (description = "Relationship type to parent" )
@@ -200,13 +200,26 @@ def resolve_devices(self, info, options=None):
200200 mylog ("none" , f"[graphql_schema] Error loading devices data: { e } " )
201201 return DeviceResult (devices = [], count = 0 )
202202
203+ # Int fields that may arrive from the DB as empty strings — coerce to None
204+ _INT_FIELDS = [
205+ "devFavorite" , "devStaticIP" , "devScan" , "devLogEvents" , "devAlertEvents" ,
206+ "devAlertDown" , "devSkipRepeated" , "devPresentLastScan" , "devIsNew" ,
207+ "devIsArchived" , "devReqNicsOnline" , "devFlapping" , "devCanSleep" , "devIsSleeping" ,
208+ ]
209+
203210 # Add dynamic fields to each device
204211 for device in devices_data :
205212 device ["devIsRandomMac" ] = 1 if is_random_mac (device ["devMac" ]) else 0
206213 device ["devParentChildrenCount" ] = get_number_of_children (
207214 device ["devMac" ], devices_data
208215 )
209- device ["devIpLong" ] = format_ip_long (device .get ("devLastIP" , "" ))
216+ # Return as string — IPv4 long values can exceed Int's signed 32-bit max (2,147,483,647)
217+ device ["devIpLong" ] = str (format_ip_long (device .get ("devLastIP" , "" )))
218+
219+ # Coerce empty strings to None so GraphQL Int serialisation doesn't fail
220+ for _field in _INT_FIELDS :
221+ if device .get (_field ) == "" :
222+ device [_field ] = None
210223
211224 mylog ("trace" , f"[graphql_schema] devices_data: { devices_data } " )
212225
0 commit comments