log and pow return positive/negative infinity as valid numbers instead of errors
Author: Sanjays2402Created Sep 25, 2026Updated Sep 28, 2026
Labelsbugnew
log() and pow() accept inputs whose true mathematical result is infinite and return them as ordinary cty.Number values with no diagnostic:
log(0, 10) => -Inf
log(10, 1) => +Inf
pow(10, 1000) => +Inf
pow(0, -1) => +InfTerraform numbers are assumed finite everywhere downstream, so the error surfaces far from the originating call:
jsonencode(pow(10, 1000))fails withcannot serialize infinity as JSONtostring(pow(10, 1000))yields the nonstandard string"+Inf"terraform consoleprints+Inf- arithmetic silently propagates it (
sum([+Inf])is+Inf), untilsum([+Inf, -Inf])errors withcan't compute sum of opposing infinities
The sibling NaN case was fixed in #38912 by rejecting math.IsNaN(result) with result is not a number, but the infinity case was missed. In internal/lang/funcs/number.go, both LogFunc and PowFunc check only math.IsNaN(result) before returning cty.NumberFloatVal(result); there is no math.IsInf check.
Expected: like NaN, an infinite result should be rejected at the originating call, mirroring #38912.
Seen on main at 55d258b (2026-09-25), version 1.18.0-dev.
Source: hashicorp/terraform