{"record":{"id":"7aaeff8c96a53d15","repo":"hashicorp/terraform","slug":"could-not-interpret-value-v-as-type-s-for-output","errorCode":null,"errorMessage":"could not interpret value %v as type %s for output %s: %w","messagePattern":"could not interpret value (.+?) as type (.+?) for output (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/state.go","lineNumber":678,"sourceCode":"\n// tfeOutputToCtyValue decodes a combination of TFE output value and detailed-type to create a\n// cty value that is suitable for use in terraform.\nfunc tfeOutputToCtyValue(output tfe.StateVersionOutput) (cty.Value, error) {\n\tvar result cty.Value\n\tbufType, err := json.Marshal(output.DetailedType)\n\tif err != nil {\n\t\treturn result, fmt.Errorf(\"could not marshal output %s type: %w\", output.ID, err)\n\t}\n\n\tvar ctype cty.Type\n\terr = ctype.UnmarshalJSON(bufType)\n\tif err != nil {\n\t\treturn result, fmt.Errorf(\"could not interpret output %s type: %w\", output.ID, err)\n\t}\n\n\tresult, err = gocty.ToCtyValue(output.Value, ctype)\n\tif err != nil {\n\t\treturn result, fmt.Errorf(\"could not interpret value %v as type %s for output %s: %w\", result, ctype.FriendlyName(), output.ID, err)\n\t}\n\n\treturn result, nil\n}\n","sourceCodeStart":660,"sourceCodeEnd":683,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/state.go#L660-L683","documentation":"The final step of tfeOutputToCtyValue coerces output.Value into the declared cty.Type via gocty.ToCtyValue. This fails when the stored value does not fit the declared type.","triggerScenarios":"A stored output value inconsistent with its declared type: e.g. a string where a number is declared, or an object missing required attributes.","commonSituations":"Corrupted state, manual state edits, or an output/provider type change between Terraform versions that left value and type out of sync.","solutions":["Inspect the named output's value versus its declared type.","Re-apply to rewrite the output consistently.","Correct the output declaration to match the actual value.","Recreate the offending output value if it is stale."],"exampleFix":"# before: declared number but stored string -> could not interpret value as type\noutput \"count\" { value = var.count }   # var.count was changed type\n# after: align declaration with the real value and re-apply\noutput \"count\" { value = tostring(var.count) }\nterraform apply","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"outs, err := state.GetRootOutputValues(ctx)\nif err != nil && strings.Contains(err.Error(), \"could not interpret value\") {\n    // value/type mismatch; align the output declaration and re-apply\n}","preventionTips":["Keep output declarations consistent with their values","Avoid manual state edits","Re-apply after changing an output's type to rewrite state consistently"],"tags":["type-mismatch","outputs","type-conversion","corruption"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}