{"record":{"id":"e7e5eb7b913ebc8d","repo":"hashicorp/nomad","slug":"value-is-not-known","errorCode":null,"errorMessage":"value is not known","messagePattern":"value is not known","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/pluginutils/hclutils/util.go","lineNumber":73,"sourceCode":"\n\tvalue, decDiag := hcldec.Decode(hclFile.Body, spec, evalCtx)\n\tdiag = diag.Extend(decDiag)\n\tif diag.HasErrors() {\n\t\treturn cty.NilVal, diag, formattedDiagnosticErrors(diag)\n\t}\n\n\treturn value, diag, nil\n}\n\n// CtyValueToMapInterface converts a decoded cty value into a Go\n// map[string]interface{}.\n//\n// ParseHclInterface returns a cty.Value and callers sometimes need a generic\n// map payload (for example for plugin config maps). This helper converts that\n// value recursively into native Go values.\nfunc CtyValueToMapInterface(val cty.Value) (map[string]any, error) {\n\tif !val.IsKnown() {\n\t\treturn nil, fmt.Errorf(\"value is not known\")\n\t}\n\n\tif val.IsNull() {\n\t\treturn nil, nil\n\t}\n\n\tt := val.Type()\n\tif !t.IsMapType() && !t.IsObjectType() {\n\t\treturn nil, fmt.Errorf(\"expected map/object cty value, got %s\", t.FriendlyName())\n\t}\n\n\tv, err := ctyValueToInterface(val)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tm, ok := v.(map[string]any)\n\tif !ok {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/pluginutils/hclutils/util.go#L55-L91","documentation":"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.","triggerScenarios":"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.","commonSituations":"Validating plugin configuration where variables/expressions have not been evaluated yet; unit tests covering the Unknown case also exercise this path.","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."],"exampleFix":"// before\nm, err := CtyValueToMapInterface(val)\n// after\nif !val.IsKnown() {\n    return nil // skip validation for unknown values\n}\nm, err := CtyValueToMapInterface(val)","handlingStrategy":"type-guard","validationCode":"if !val.IsKnown() {\n    return nil // defer validation until value is known\n}\nmapVal, err := hclutils.CtyValueToMapInterface(val)","typeGuard":"func isKnownMap(v cty.Value) bool {\n    return v.IsKnown() && !v.IsNull() &&\n        (v.Type().IsMapType() || v.Type().IsObjectType())\n}","tryCatchPattern":"m, err := CtyValueToMapInterface(val)\nif err != nil && err.Error() == \"value is not known\" {\n    return nil // skip validation for unknown values\n} else if err != nil {\n    return err\n}","preventionTips":["Evaluate HCL expressions/variables before validating plugin config","Check IsKnown() at each conversion boundary","Keep test coverage for unknown-value cases"],"tags":["cty","hcl","go"],"backgroundTag":"unknown-cty-value","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}