hashicorp/nomad · error

value is not known

Error message

value is not known

What it means

interfaceFromCtyValue converts a cty.Value to a Go interface{} for a given cty.Type. Null values convert to nil, but if the value is not known (result of unevaluated expressions, e.g. variables without values), conversion cannot proceed and this error is returned.

Source

Thrown at jobspec2/parse_map.go:92

			Summary:  "unsuitable value type",
			Detail:   fmt.Sprintf("Unsuitable value: %s", err.Error()),
			Subject:  expr.StartRange().Ptr(),
			Context:  expr.Range().Ptr(),
		})
	}

	return dst, diags
}

func interfaceFromCtyValue(val cty.Value) (any, error) {
	t := val.Type()

	if val.IsNull() {
		return nil, nil
	}

	if !val.IsKnown() {
		return nil, fmt.Errorf("value is not known")
	}

	// The caller should've guaranteed that the given val is conformant with
	// the given type t, so we'll proceed under that assumption here.

	switch {
	case t.IsPrimitiveType():
		switch t {
		case cty.String:
			return val.AsString(), nil
		case cty.Number:
			if val.RawEquals(cty.PositiveInfinity) {
				return math.Inf(1), nil
			} else if val.RawEquals(cty.NegativeInfinity) {
				return math.Inf(-1), nil
			} else {
				return smallestNumber(val.AsBigFloat()), nil
			}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Provide values for all referenced variables via -var flags or var files so the cty value becomes known.
  2. Check that variable declarations have defaults where values may be omitted.
  3. Trace which expression produced the unknown value and simplify or remove it.
  4. Ensure decode is called after full evaluation of the config body, not on a partially-processed HCL file.

Example fix

// before
nomad job run job.nomad // job uses var.region, but region never supplied -> unknown

// after
nomad job run -var region=us-east-1 job.nomad
Defensive patterns

Strategy: validation

Validate before calling

// Ensure every referenced variable has a value before parsing
for name := range referencedVars {
    if _, ok := suppliedVars[name]; !ok && !hasDefault(name) {
        return fmt.Errorf("variable %q has no value; would decode as unknown", name)
    }
}

Try / catch

v, err := interfaceFromCtyValue(val, t)
if err != nil && err.Error() == "value is not known" {
    // supply missing vars and re-evaluate
}

Prevention

When it happens

Trigger: decodeInterface or recursive interfaceFromCtyValue encountering a cty.Value where IsKnown() is false — typically when a variable reference was never given a value, leaving unknown placeholders in the decoded structure.

Common situations: Jobspec referencing variables not supplied via -var/var-file; evaluation of expressions producing unknown values (division by unknown, unset inputs); converting partially-evaluated config bodies.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/fb9637213f560fcc. Report an issue: GitHub.