From 05c27d982f26cfb066a1b07af94e784701c8e31b Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 19 Nov 2025 16:51:54 -0800 Subject: [PATCH] main: Warn in logs if GODEBUG is set The GODEBUG environment variable is a side-channel that allows dynamically opting in to a million billion different variations of Go runtime and standard library behavior, and we can obviously not routinely test OpenTofu's behavior across all of those different variations. Just in case someone encounters a problem caused by running OpenTofu with a combination of settings that are not enabled in our default build configuration, we'll include an explicit note in the logs so that we can tell when we're investigating a bug report that it might only be reproducible when the Go runtime behavior has been overridden in this way, and so that someone debugging their own problem can notice that they are using OpenTofu in an unsupported way and could potentially solve their own problem by unsetting that environment variable. This is a generalization of the previous addition of a log message when running in FIPS 140-3 mode, which is also updated here to use [WARN] instead of [WARNING] as the prefix because our logging system does not actually understand "WARNING" as a valid prefix. Keeping the separate specialized message for FIPS 140-3 mode is warranted because we _know_ that OpenTofu does not behave as intended when that mode is enabled, while we've not tested with any other combination of settings so we cannot predict whether they will cause misbehavior or not. Signed-off-by: Martin Atkins --- cmd/tofu/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/tofu/main.go b/cmd/tofu/main.go index 76c4bfdb77..5dc6701f36 100644 --- a/cmd/tofu/main.go +++ b/cmd/tofu/main.go @@ -129,8 +129,11 @@ func realMain() int { log.Printf("[DEBUG] using %s %s", depMod.Path, depMod.Version) } log.Printf("[INFO] Go runtime version: %s", runtime.Version()) + if dynamicGodebug := os.Getenv("GODEBUG"); dynamicGodebug != "" { + log.Printf("[WARN] GODEBUG environment variable is set to %q, which may activate unsupported and untested behavior", dynamicGodebug) + } if fips140.Enabled() { - log.Printf("[WARNING] Go runtime FIPS 140-3 mode is enabled; OpenTofu is not supported in this configuration, which may cause undesirable behavior") + log.Printf("[WARN] Go runtime FIPS 140-3 mode is enabled; OpenTofu is not supported in this configuration, which may cause undesirable behavior") } log.Printf("[INFO] CLI args: %#v", os.Args) if experimentsAreAllowed() {