{"record":{"id":"0a2121704241f7ef","repo":"hashicorp/terraform","slug":"error-reading-output-values-s","errorCode":null,"errorMessage":"error reading output values: %s","messagePattern":"error reading output values: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote/backend_state.go","lineNumber":122,"sourceCode":"\t\treturn fmt.Errorf(\"error uploading state in compatibility mode: %v\", err)\n\t}\n\treturn err\n}\n\n// Put the remote state.\nfunc (r *remoteClient) Put(state []byte) tfdiags.Diagnostics {\n\tvar diags tfdiags.Diagnostics\n\tctx := context.Background()\n\n\t// Read the raw state into a Terraform state.\n\tstateFile, err := statefile.Read(bytes.NewReader(state))\n\tif err != nil {\n\t\treturn diags.Append(fmt.Errorf(\"error reading state: %s\", err))\n\t}\n\n\tov, err := jsonstate.MarshalOutputs(stateFile.State.RootOutputValues)\n\tif err != nil {\n\t\treturn diags.Append(fmt.Errorf(\"error reading output values: %s\", err))\n\t}\n\to, err := json.Marshal(ov)\n\tif err != nil {\n\t\treturn diags.Append(fmt.Errorf(\"error converting output values to json: %s\", err))\n\t}\n\n\toptions := tfe.StateVersionUploadOptions{\n\t\tStateVersionCreateOptions: tfe.StateVersionCreateOptions{\n\t\t\tLineage:          tfe.String(stateFile.Lineage),\n\t\t\tSerial:           tfe.Int64(int64(stateFile.Serial)),\n\t\t\tMD5:              tfe.String(fmt.Sprintf(\"%x\", md5.Sum(state))),\n\t\t\tForce:            tfe.Bool(r.forcePush),\n\t\t\tJSONStateOutputs: tfe.String(base64.StdEncoding.EncodeToString(o)),\n\t\t},\n\t\tRawState: state,\n\t}\n\n\t// If we have a run ID, make sure to add it to the options","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote/backend_state.go#L104-L140","documentation":"Emitted by remoteClient.Put (backend_state.go:120-123) when jsonstate.MarshalOutputs cannot serialize the RootOutputValues from the parsed state file. MarshalOutputs converts the in-memory state outputs into the JSON representation stored alongside the state version in TFC. Failure means the output values in the state could not be converted to that JSON model.","triggerScenarios":"The state's RootOutputValues contain a value shape MarshalOutputs cannot handle — typically a state-format-version mismatch where outputs carry types/markers the jsonstate package in this build does not recognize.","commonSituations":"State written by a newer Terraform with extended value types, read by an older build; a provider produced an output value with an unusual cty type; partial/legacy state from an older schema.","solutions":["Use a Terraform build whose jsonstate package matches the state format version that wrote the outputs.","Regenerate state from scratch (import resources) if the outputs are irrecoverably malformed.","Inspect the wrapped %s diagnostic to see which output value/type MarshalOutputs rejected, then fix or remove that output in config.","If migrating versions, upgrade Terraform CLI rather than downgrading, to pick up newer output type support."],"exampleFix":"// before\nError: error reading output values: unsupported marker type \"SensitiveObject\"\n\n// after: upgrade Terraform to a version supporting the output type, then re-apply\n$ terraform version  # ensure >= version that wrote the state\n$ terraform apply","handlingStrategy":"validation","validationCode":"// Confirm the state format version is one this build understands before marshaling.\nif stateFile == nil || stateFile.State == nil {\n    return errors.New(\"cannot marshal outputs from empty state\")\n}\nif stateFile.TerraformVersion != nil && unsupportedVersion(stateFile.TerraformVersion) {\n    return fmt.Errorf(\"state written by unsupported version %s\", stateFile.TerraformVersion)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a Terraform CLI version matching or newer than the one that wrote the state.","Avoid provider outputs with exotic types that jsonstate may not handle.","When downgrading Terraform, run a clean apply rather than reusing newer state.","Inspect the wrapped diagnostic to identify the offending output value type."],"tags":["state","outputs","marshaling","version-mismatch"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}