hashicorp/terraform · error

invalid retry_wait_min: %s

Error message

invalid retry_wait_min: %s

What it means

Same IntValue conversion path as retry_max but for retry_wait_min (default 1 second, env TF_HTTP_RETRY_WAIT_MIN). It bounds the minimum backoff delay between retryablehttp attempts. A fractional, missing, or out-of-range number produces this error wrapped with the IntValue failure.

Source

Thrown at internal/backend/remote-state/http/backend.go:206

		backendbase.GetAttrEnvDefaultFallback(
			configVal, "retry_max",
			"TF_HTTP_RETRY_MAX", cty.NumberIntVal(2),
		),
	)
	if err != nil {
		return backendbase.ErrorAsDiagnostics(
			fmt.Errorf("invalid retry_max: %s", err),
		)
	}
	retryWaitMin, err := backendbase.IntValue(
		backendbase.GetAttrEnvDefaultFallback(
			configVal, "retry_wait_min",
			"TF_HTTP_RETRY_WAIT_MIN", cty.NumberIntVal(1),
		),
	)
	if err != nil {
		return backendbase.ErrorAsDiagnostics(
			fmt.Errorf("invalid retry_wait_min: %s", err),
		)
	}
	retryWaitMax, err := backendbase.IntValue(
		backendbase.GetAttrEnvDefaultFallback(
			configVal, "retry_wait_max",
			"TF_HTTP_RETRY_WAIT_MAX", cty.NumberIntVal(30),
		),
	)
	if err != nil {
		return backendbase.ErrorAsDiagnostics(
			fmt.Errorf("invalid retry_wait_max: %s", err),
		)
	}

	rClient := retryablehttp.NewClient()
	rClient.RetryMax = int(retryMax)
	rClient.RetryWaitMin = time.Duration(retryWaitMin) * time.Second
	rClient.RetryWaitMax = time.Duration(retryWaitMax) * time.Second

View on GitHub (pinned to c9def3e214)

Solutions

  1. Set retry_wait_min to a positive integer representing seconds (e.g. retry_wait_min = 1).
  2. Drop the attribute to use the default of 1 second.
  3. Confirm TF_HTTP_RETRY_WAIT_MIN holds a bare integer, not a Go duration string.

Example fix

// before
retry_wait_min = "1s"
// after
retry_wait_min = 1
Defensive patterns

Strategy: validation

Validate before calling

func validateRetryWait(v interface{}, name string) error {
  n, ok := v.(int)
  if !ok { return fmt.Errorf("%s must be int seconds", name) }
  if n < 0 { return fmt.Errorf("%s must be >= 0", name) }
  return nil
}

Type guard

func isRetryWait(v cty.Value) bool {
  return v.Type() == cty.Number && !v.IsNull() && v.AsBigFloat().IsInt()
}

Prevention

When it happens

Trigger: Setting retry_wait_min to a float like 0.5, a negative number, or a value HCL cannot coerce to int. Fires at Configure time.

Common situations: Operator assumes seconds can be fractional (0.5s); passes a duration string "1s" instead of a number; copies a value from a config that used milliseconds.

Related errors


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