OrganizationApplianceUplinksUsageByNetworkItemByUplinkItem.Sent/.Received are Int32, overflow on real-world traffic volumes and throw JsonReaderException
Environment
- Package: Meraki.Api 1.70.45
- Target: .NET 9.0
Summary
GET /organizations/{organizationId}/appliance/uplinks/usageByNetwork returns cumulative sent/received byte counts per uplink for the requested time window (up to 31 days). For networks with enough traffic, these values routinely exceed Int32.MaxValue (~2.1 GB) over a 24-hour window, let alone 31 days.
OrganizationApplianceUplinksUsageByNetworkItemByUplinkItem.Sent and .Received are declared as Int32. When Meraki's API returns a value larger than Int32.MaxValue, Newtonsoft.Json throws a JsonReaderException while deserializing the response body, which Refit wraps in an ApiException. The whole call fails — there is no partial result — so the metric is unusable for any network busy enough to trigger it.
Verified by reflection against the shipped 1.70.45 assembly (Meraki.Api.dll, net10.0 and netstandard2.0 TFMs — same types in both):
var t = typeof(Meraki.Api.MerakiClient).Assembly.GetTypes()
.First(x => x.Name == "OrganizationApplianceUplinksUsageByNetworkItemByUplinkItem");
foreach (var p in t.GetProperties())
Console.WriteLine($"{p.Name}: {p.PropertyType.FullName}");
// Received: System.Int32
// Sent: System.Int32
// Interface: System.String
// Serial: System.String
Confirmed present in both 1.70.37 and 1.70.45 — unrelated to, and not touched by, the #337/#358 organization Refit-client-wiring fix.
Expected behavior
Sent/.Received should be wide enough to hold any value Meraki's own API can return for a 31-day cumulative byte count — long (Int64), matching the pattern already used elsewhere in the SDK for cumulative counters.
Actual behavior
var usage = await client.Organizations.Appliance.Uplinks.Usage
.GetOrganizationApplianceUplinksUsageByNetworkAsync(organizationId, cancellationToken);
throws:
Refit.ApiException: An error occurred while deserializing the response
---> Newtonsoft.Json.JsonReaderException: JSON integer ... is too large or small for an Int32 ...
for any network whose uplink traffic in the requested window exceeds ~2.1 GB on a single uplink. This is a common, not edge-case, volume for a business network over even a single day.
Suggested fix
Widen OrganizationApplianceUplinksUsageByNetworkItemByUplinkItem.Sent and .Received from int/Int32 to long/Int64. This is a binary-compatible widening for callers using implicit typing (var) but a source break for anyone who declared the property type explicitly.
Worth auditing other cumulative byte/traffic-count DTOs in the SDK for the same narrow-int pattern while this is being fixed — this one was only found because it broke a specific sync path.
OrganizationApplianceUplinksUsageByNetworkItemByUplinkItem.Sent/.Received are Int32, overflow on real-world traffic volumes and throw JsonReaderException
Environment
Summary
GET /organizations/{organizationId}/appliance/uplinks/usageByNetwork returns cumulative sent/received byte counts per uplink for the requested time window (up to 31 days). For networks with enough traffic, these values routinely exceed Int32.MaxValue (~2.1 GB) over a 24-hour window, let alone 31 days.
OrganizationApplianceUplinksUsageByNetworkItemByUplinkItem.Sent and .Received are declared as Int32. When Meraki's API returns a value larger than Int32.MaxValue, Newtonsoft.Json throws a JsonReaderException while deserializing the response body, which Refit wraps in an ApiException. The whole call fails — there is no partial result — so the metric is unusable for any network busy enough to trigger it.
Verified by reflection against the shipped 1.70.45 assembly (Meraki.Api.dll, net10.0 and netstandard2.0 TFMs — same types in both):
Expected behavior
Sent/.Received should be wide enough to hold any value Meraki's own API can return for a 31-day cumulative byte count — long (Int64), matching the pattern already used elsewhere in the SDK for cumulative counters.
Actual behavior
throws:
Suggested fix
Widen OrganizationApplianceUplinksUsageByNetworkItemByUplinkItem.Sent and .Received from int/Int32 to long/Int64. This is a binary-compatible widening for callers using implicit typing (var) but a source break for anyone who declared the property type explicitly.
Worth auditing other cumulative byte/traffic-count DTOs in the SDK for the same narrow-int pattern while this is being fixed — this one was only found because it broke a specific sync path.