Loading...
Loading...
### Terraform Version ```shell Terraform v1.15.6 on darwin_arm64 ``` ### Terraform Configuration Files No Terraform configuration is required. The issue reproduces directly in `terraform console` with ordinary scalar expressions: ```terraform log(-1, 10) log(1, 1) pow(-2, 0.5) ``` ### Debug Output A separate `TF_LOG` debug log is not needed to reproduce this. The console output itself includes the internal panic and stack trace. Excerpt: ```text Call to function "log" failed: panic in function implementation: Float.SetFloat64(NaN) ... github.com/zclconf/go-cty/cty.NumberFloatVal(...) ``` `pow(-2, 0.5)` fails the same way, through `Float.SetFloat64(NaN)`. ### Expected Behavior Terraform should return a normal function-call diagnostic for inputs whose mathematical result is undefined / NaN, rather than exposing an internal panic and Go stack trace to the user. ### Actual Behavior `log()` and `pow()` can produce `NaN` for validly-typed scalar inputs. That `NaN` is then passed to `cty.NumberFloatVal`, which is backed by `big.Float` and panics on `Float.SetFloat64(NaN)`. The panic is surfaced to the user as: ```text panic in function implementation: Float.SetFloat64(NaN) ``` followed by a full stack trace. Examples: - `log(-1, 10)` - logarithm of a negative number - `log(1, 1)` - base 1 gives `0/0` - `pow(-2, 0.5)` - negative base raised to a fractional power ### Steps to Reproduce 1. Run `printf "log(-1, 10)\n" | terraform console` 2. Run `printf "log(1, 1)\n" | terraform console` 3. Run `printf "pow(-2, 0.5)\n" | terraform console` ### Additional Context This is not tied to providers or external services. It is a Terraform language function behavior. Go `math.Log` / `math.Pow` return `NaN` for these cases, and `cty.NumberFloatVal` cannot accept `NaN`. ### References - #38883
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
BugZero Plan
Streamline upgrades with automated vendor bug scrubs
BugZero Prevent
Wish you caught this bug sooner? Get proactive today.