{"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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote/backend_state.go#L104-L140","documentation":"After parsing the state file, Put calls jsonstate.MarshalOutputs on stateFile.State.RootOutputValues to derive the JSON output map TFC stores alongside the state. Failure here means the in-memory state's output values can't be converted to the JSON-serializable form TFC expects.","triggerScenarios":"jsonstate.MarshalOutputs returns an error: an output value has a type or marked-sensitive shape the marshaler can't handle (e.g. a value type introduced in a newer core than the jsonstate package understands), or internal state struct invariants are violated.","commonSituations":"Version mismatch where core produced outputs (new cty refinement / nested type) that the bundled jsonstate MarshalOutputs can't encode; experimental features in use; corrupted in-memory state after a partial refresh.","solutions":["Use a Terraform build where core's output types and jsonstate.MarshalOutputs are in sync (rebuild/pin a consistent version).","Reduce outputs to plain primitive types to isolate which output value triggers the marshal failure.","Report the failing output type/marking — this is generally an internal bug, not a config-level fix."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Capture the marshal error and degrade gracefully\nov, err := jsonstate.MarshalOutputs(s.RootOutputValues)\nif err != nil {\n    log.Printf(\"output marshal failed (%v); uploading state without JSON outputs\", err)\n    ov = nil // proceed with nil outputs rather than aborting\n}","preventionTips":["Keep core and jsonstate versions aligned (don't mix fork components).","Prefer plain primitive outputs when integrating with downstream consumers.","Report persistent marshal failures with the output type detail."],"tags":["terraform","remote-backend","state","outputs","serialization","internal"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}