Skip to content

Commit f955226

Browse files
authored
docs: extend NaN/Inf guidance to cover runtime query boundaries (#182)
The Float parsing section only covered strconv.ParseFloat. The SLO monitor bug (PR #167) showed that Prometheus queries and other external systems can return NaN/Inf at runtime without any string parsing. Broaden the rule to cover all float64 values received from external boundaries. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent aa41ba6 commit f955226

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ with NaN return false, silently disabling any threshold or guardrail that uses
9999
the parsed value. Always check `math.IsNaN(v) || math.IsInf(v, 0)` after
100100
`strconv.ParseFloat` in validation code.
101101

102+
The same guard applies at **runtime query boundaries**, not just parse-time.
103+
Prometheus queries, API responses, and external computations can return NaN
104+
(e.g., `0/0` in PromQL) or Inf without any string parsing involved. Any
105+
`float64` received from an external system must be checked before comparison.
106+
Example: `internal/safety/monitor.go` SLO query values (PR #167),
107+
`internal/metrics/collector.go` `GetThrottleRatio` (line 349).
108+
102109
### Webhooks
103110

104111
controller-runtime v0.24.x uses typed generic interfaces. Register webhooks with:

0 commit comments

Comments
 (0)