hashicorp/terraform · error

no non-null, non-empty-string arguments

Error message

no non-null, non-empty-string arguments

What it means

Thrown by `coalesce()` (CoalesceFunc) in its Impl when every variadic argument is either null or — for strings — an empty string. coalesce is defined to return the first non-null, non-empty-string value; if none qualify, it has nothing to return and errors. This is the 'no useful value found' terminal condition.

Solutions

  1. Provide at least one argument that is non-null and (if string) non-empty.
  2. Use a guaranteed non-empty literal fallback as the last argument.
  3. If empty-string is legitimately acceptable, use `one(...)` or `try(...)` instead of coalesce, since coalesce intentionally excludes empty strings.

Example fix

// before
locals { region = coalesce(var.region, var.default_region, "") }

// after
locals { region = coalesce(var.region, var.default_region, "us-east-1") }
Defensive patterns

Strategy: fallback

Validate before calling

# HCL: guarantee at least one non-empty fallback
locals { out = coalesce(var.a, var.b, "__DEFAULT__") }

Type guard

# HCL: prefer try() if empty-string/null are acceptable
locals { out = try(var.a, var.b, "") }

Prevention

When it happens

Trigger: All inputs are null or empty string: `coalesce(null, "", null)`. All optional variables unset and defaults empty.

Common situations: A lookup chain where every variable is unset and the final fallback is itself empty: `coalesce(var.a, var.b, "")`. Conditional config where all branches collapse to empty in the current workspace.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/b9fd96ba236ed77e. Report an issue: GitHub.

Appendix: source

Thrown at internal/lang/funcs/collection.go:173

	},
	RefineResult: refineNotNull,
	Impl: func(args []cty.Value, retType cty.Type) (ret cty.Value, err error) {
		for _, argVal := range args {
			// We already know this will succeed because of the checks in our Type func above
			argVal, _ = convert.Convert(argVal, retType)
			if !argVal.IsKnown() {
				return cty.UnknownVal(retType), nil
			}
			if argVal.IsNull() {
				continue
			}
			if retType == cty.String && argVal.RawEquals(cty.StringVal("")) {
				continue
			}

			return argVal, nil
		}
		return cty.NilVal, errors.New("no non-null, non-empty-string arguments")
	},
})

// IndexFunc constructs a function that finds the element index for a given value in a list.
var IndexFunc = function.New(&function.Spec{
	Params: []function.Parameter{
		{
			Name: "list",
			Type: cty.DynamicPseudoType,
		},
		{
			Name: "value",
			Type: cty.DynamicPseudoType,
		},
	},
	Type:         function.StaticReturnType(cty.Number),
	RefineResult: refineNotNull,
	Impl: func(args []cty.Value, retType cty.Type) (ret cty.Value, err error) {

View on GitHub (pinned to d32a084675)