{"record":{"id":"fb9637213f560fcc","repo":"hashicorp/nomad","slug":"value-is-not-known-fb9637","errorCode":null,"errorMessage":"value is not known","messagePattern":"value is not known","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"jobspec2/parse_map.go","lineNumber":92,"sourceCode":"\t\t\tSummary:  \"unsuitable value type\",\n\t\t\tDetail:   fmt.Sprintf(\"Unsuitable value: %s\", err.Error()),\n\t\t\tSubject:  expr.StartRange().Ptr(),\n\t\t\tContext:  expr.Range().Ptr(),\n\t\t})\n\t}\n\n\treturn dst, diags\n}\n\nfunc interfaceFromCtyValue(val cty.Value) (any, error) {\n\tt := val.Type()\n\n\tif val.IsNull() {\n\t\treturn nil, nil\n\t}\n\n\tif !val.IsKnown() {\n\t\treturn nil, fmt.Errorf(\"value is not known\")\n\t}\n\n\t// The caller should've guaranteed that the given val is conformant with\n\t// the given type t, so we'll proceed under that assumption here.\n\n\tswitch {\n\tcase t.IsPrimitiveType():\n\t\tswitch t {\n\t\tcase cty.String:\n\t\t\treturn val.AsString(), nil\n\t\tcase cty.Number:\n\t\t\tif val.RawEquals(cty.PositiveInfinity) {\n\t\t\t\treturn math.Inf(1), nil\n\t\t\t} else if val.RawEquals(cty.NegativeInfinity) {\n\t\t\t\treturn math.Inf(-1), nil\n\t\t\t} else {\n\t\t\t\treturn smallestNumber(val.AsBigFloat()), nil\n\t\t\t}","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/jobspec2/parse_map.go#L74-L110","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Provide values for all referenced variables via -var flags or var files so the cty value becomes known.","Check that variable declarations have defaults where values may be omitted.","Trace which expression produced the unknown value and simplify or remove it.","Ensure decode is called after full evaluation of the config body, not on a partially-processed HCL file."],"exampleFix":"// before\nnomad job run job.nomad // job uses var.region, but region never supplied -> unknown\n\n// after\nnomad job run -var region=us-east-1 job.nomad","handlingStrategy":"validation","validationCode":"// Ensure every referenced variable has a value before parsing\nfor name := range referencedVars {\n    if _, ok := suppliedVars[name]; !ok && !hasDefault(name) {\n        return fmt.Errorf(\"variable %q has no value; would decode as unknown\", name)\n    }\n}","typeGuard":null,"tryCatchPattern":"v, err := interfaceFromCtyValue(val, t)\nif err != nil && err.Error() == \"value is not known\" {\n    // supply missing vars and re-evaluate\n}","preventionTips":["Always pass -var or var files for variables without defaults.","Give variables sensible defaults in declarations.","Avoid expressions that can yield unknown values in job specs."],"tags":["hcl","cty","jobspec","unknown-value"],"backgroundTag":"unknown-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"}