{"record":{"id":"c1996e4e94454f80","repo":"hashicorp/terraform","slug":"could-not-interpret-output-s-type-w","errorCode":null,"errorMessage":"could not interpret output %s type: %w","messagePattern":"could not interpret output (.+?) type: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/state.go","lineNumber":673,"sourceCode":"\n\t// We will only enable snapshots for intervals greater than zero\n\tlog.Printf(\"[TRACE] Intermediate state interval is set by header to %v\", s.stateSnapshotInterval)\n\ts.enableIntermediateSnapshots = s.stateSnapshotInterval > 0\n}\n\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":655,"sourceCodeEnd":683,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/state.go#L655-L683","documentation":"Thrown inside tfeOutputToCtyValue after the DetailedType is JSON-marshaled but cty.Type.UnmarshalJSON cannot interpret that JSON as a valid cty type. The cty type encoding has a specific JSON format (type markers like \"string\", [\"object\",...], [\"list\",...], etc.); any deviation causes this error. The %w wraps the cty unmarshal error and includes the output ID.","triggerScenarios":"The DetailedType JSON uses an unknown or malformed type marker; a nested type exceeds cty's supported depth; the type JSON is a valid JSON value but not a valid cty type specification; terraform's embedded cty version is older than the TFE server's type encoding.","commonSituations":"TFE server upgraded to emit a new type encoding before the terraform client supports it; a provider output with an exotic type (e.g. abstract type, optional object attributes) not supported by the client's cty version; corrupt state data.","solutions":["Upgrade terraform to the latest release so its cty library understands newer type encodings","Identify the offending output via TF_LOG and simplify its type in configuration","Re-apply with a current terraform version to rewrite the state with a compatible type encoding","If on self-hosted TFE, align TFE and terraform CLI versions to compatible release lines"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate that the type JSON is a valid cty type before full conversion:\nbufType, _ := json.Marshal(output.DetailedType)\nvar t cty.Type\nif err := t.UnmarshalJSON(bufType); err != nil {\n    log.Printf(\"[WARN] output %s type JSON is not a valid cty type: %v\", output.ID, err)\n}","typeGuard":null,"tryCatchPattern":"_, err := state.GetRootOutputValues(ctx)\nif err != nil && strings.Contains(err.Error(), \"could not interpret output\") {\n    // cty cannot parse the type encoding from TFE — version mismatch likely\n    return fmt.Errorf(\"cty type interpretation failed; align terraform and TFE versions: %w\", err)\n}","preventionTips":["Align terraform CLI version with the TFE/HCP Terraform server version to avoid type-encoding gaps","After upgrading TFE, run a test output read before large operations","Pin terraform CLI versions in CI to match the tested TFE release line"],"tags":["outputs","cty","type-decoding","json","tfe","terraform"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}