{"record":{"id":"28adbda454861e96","repo":"hashicorp/terraform","slug":"preparing-attribute-values-for-s-w","errorCode":null,"errorMessage":"preparing attribute values for %s: %w","messagePattern":"preparing attribute values for (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/jsonstate/state.go","lineNumber":452,"sourceCode":"\t\t\t\t\t}\n\n\t\t\t\t\tif schema.Identity == nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"no resource identity schema found for %s (in provider %s)\", resAddr.String(), r.ProviderConfig.Provider)\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrent.IdentitySchemaVersion = &ri.Current.IdentitySchemaVersion\n\t\t\t\t}\n\n\t\t\t\triObj, err := ri.Current.Decode(schema)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\tvar value cty.Value\n\t\t\t\tvar sensitivePaths []cty.Path\n\t\t\t\tvalue, current.AttributeValues, sensitivePaths, err = marshalAttributeValues(riObj.Value)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"preparing attribute values for %s: %w\", current.Address, err)\n\t\t\t\t}\n\t\t\t\tsensitivePaths = append(sensitivePaths, schema.Body.SensitivePaths(value, nil)...)\n\t\t\t\ts := SensitiveAsBool(marks.MarkPaths(value, marks.Sensitive, sensitivePaths))\n\t\t\t\tv, err := ctyjson.Marshal(s, s.Type())\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tcurrent.SensitiveValues = v\n\n\t\t\t\tcurrent.IdentityValues, err = marshalIdentityValues(riObj.Identity)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"preparing identity values for %s: %w\", current.Address, err)\n\t\t\t\t}\n\n\t\t\t\tif len(riObj.Dependencies) > 0 {\n\t\t\t\t\tdependencies := make([]string, len(riObj.Dependencies))\n\t\t\t\t\tfor i, v := range riObj.Dependencies {\n\t\t\t\t\t\tdependencies[i] = v.String()","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/jsonstate/state.go#L434-L470","documentation":"Thrown by jsonstate while marshaling the current resource instance: marshalAttributeValues(riObj.Value) failed and the error is wrapped with the resource address. The underlying cause is a cty value (decoded via ri.Current.Decode(schema)) that cannot be transcoded into the JSON attribute map, typically because its type/shape disagrees with what marshalAttributeValues expects or it carries unhandled marks.","triggerScenarios":"The decoded resource value has a nested type marshalAttributeValues cannot walk; a value carries an unhandled cty mark; provider schema/data mismatch producing a malformed value; corrupt state bytes that decode to an unexpected shape.","commonSituations":"State written by an incompatible provider/Terraform version; provider returning attributes whose types changed without a schema-version bump; manually edited state.","solutions":["Run `terraform apply -refresh-only` to recompute the instance value from the provider.","Align provider and Terraform versions with the state's origin.","Inspect the wrapped error (the %w) for the precise marshal failure and address that root cause.","If state is corrupt, restore from backup or use `terraform state pull`/edit/`push` to repair the instance."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := jsonstate.Marshal(state, schemas); err != nil {\n    var se interface{ Unwrap() error }\n    if errors.As(err, &se) {\n        // inspect the wrapped marshal failure to pinpoint the attribute/type\n        log.Printf(\"attribute marshal failed: %v\", se.Unwrap())\n    }\n    return err\n}","preventionTips":["Run `terraform apply -refresh-only` to recompute instance values after provider/schema changes.","Keep provider and Terraform versions consistent with the state's origin.","Inspect the wrapped (%w) error to find the exact attribute/type that failed."],"tags":["terraform","json-state","attribute-values","serialization","cty"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}