Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(querybuildertypesv5): guard float overflow in roundToNonZeroDecimals (#12151)

Srikanth Chekuri6b065aa54c69
diff --git a/pkg/types/querybuildertypes/querybuildertypesv5/resp.go b/pkg/types/querybuildertypes/querybuildertypesv5/resp.go
index c0aa6c260b..190670d5aa 100644
--- a/pkg/types/querybuildertypes/querybuildertypesv5/resp.go
+++ b/pkg/types/querybuildertypes/querybuildertypesv5/resp.go
@@ -328,6 +328,11 @@ func roundToNonZeroDecimals(val float64, n int) float64 {
// Round to n decimal places
multiplier := math.Pow(10, float64(n))
rounded := math.Round(val*multiplier) / multiplier
+ if math.IsInf(rounded, 0) {
+ // val*multiplier overflowed for near-max float64 values; the
+ // finite input must stay finite or the JSON encoder rejects it.
+ return val
+ }
// If the result is a whole number, return it as such
if rounded == math.Trunc(rounded) {