hashicorp/nomad · error
value is not known
Error message
value is not known
What it means
CtyValueToMapInterface converts a cty.Value (from ParseHclInterface) into a native Go map. cty unknown values represent values not yet decided (e.g. from expressions or marks); they cannot be materialized, so the helper rejects them up front with this error.
Source
Thrown at helper/pluginutils/hclutils/util.go:73
value, decDiag := hcldec.Decode(hclFile.Body, spec, evalCtx)
diag = diag.Extend(decDiag)
if diag.HasErrors() {
return cty.NilVal, diag, formattedDiagnosticErrors(diag)
}
return value, diag, nil
}
// CtyValueToMapInterface converts a decoded cty value into a Go
// map[string]interface{}.
//
// ParseHclInterface returns a cty.Value and callers sometimes need a generic
// map payload (for example for plugin config maps). This helper converts that
// value recursively into native Go values.
func CtyValueToMapInterface(val cty.Value) (map[string]any, error) {
if !val.IsKnown() {
return nil, fmt.Errorf("value is not known")
}
if val.IsNull() {
return nil, nil
}
t := val.Type()
if !t.IsMapType() && !t.IsObjectType() {
return nil, fmt.Errorf("expected map/object cty value, got %s", t.FriendlyName())
}
v, err := ctyValueToInterface(val)
if err != nil {
return nil, err
}
m, ok := v.(map[string]any)
if !ok {View on GitHub (pinned to 482b49bf1a)
Solutions
- Evaluate/resolve the HCL expressions so the value is known before converting.
- Guard with val.IsKnown() and skip or defer conversion for unknown values.
- If validating, treat unknown as 'defer' rather than an error in your caller.
Example fix
// before
m, err := CtyValueToMapInterface(val)
// after
if !val.IsKnown() {
return nil // skip validation for unknown values
}
m, err := CtyValueToMapInterface(val) Defensive patterns
Strategy: type-guard
Validate before calling
if !val.IsKnown() {
return nil // defer validation until value is known
}
mapVal, err := hclutils.CtyValueToMapInterface(val) Type guard
func isKnownMap(v cty.Value) bool {
return v.IsKnown() && !v.IsNull() &&
(v.Type().IsMapType() || v.Type().IsObjectType())
} Try / catch
m, err := CtyValueToMapInterface(val)
if err != nil && err.Error() == "value is not known" {
return nil // skip validation for unknown values
} else if err != nil {
return err
} Prevention
- Evaluate HCL expressions/variables before validating plugin config
- Check IsKnown() at each conversion boundary
- Keep test coverage for unknown-value cases
When it happens
Trigger: Passing a cty.Value whose IsKnown() is false to CtyValueToMapInterface — typically from validatePluginConfig handling plugin config, or HCL containing expressions that evaluate to unknown during validation.
Common situations: Validating plugin configuration where variables/expressions have not been evaluated yet; unit tests covering the Unknown case also exercise this path.
Related errors
- expected map/object cty value, got %s
- invalid key: %s
- expected map/object cty value, got %T
- cannot serialize %s
- %s: %s
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/e7e5eb7b913ebc8d.
Report an issue: GitHub.