{"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":"console","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/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/jsonstate/state.go#L434-L470","documentation":"Wraps an error from marshalAttributeValues while serializing the current (non-deposed) resource instance's attributes in state. The %w carries the underlying cause (typically a value that cannot be marshaled, e.g. an unserializable cty mark). The message identifies which resource's attributes failed so the offending instance can be located.","triggerScenarios":"Raised in jsonstate when marshalAttributeValues(riObj.Value) returns a non-nil error for the current instance. Commonly the inner error is the unmarkValueForMarshaling failure (cannot serialize a value marked with an unrecognized mark) or a cty JSON marshal failure.","commonSituations":"Most often a downstream symptom of error 632 (unsupported cty mark in state). Also occurs with provider bugs that produce non-serializable values, or after partial state corruption. Triggered by any JSON state/plan rendering command.","solutions":["Read the wrapped (%w) error text — it identifies the real cause (e.g. 'cannot serialize value marked as ...').","Upgrade Terraform Core and the relevant provider; unsupported marks are usually internal bugs fixed in newer releases.","If tied to one resource, `terraform state rm` it and re-import/re-apply to rewrite a clean object.","Restore state from terraform.tfstate.backup if the corruption was introduced recently."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := jsonstate.MarshalCurrentAttributes(riObj); err != nil {\n    // Read the wrapped cause; if it's an unserializable mark, treat as internal bug and skip the instance.\n    return fmt.Errorf(\"attribute serialization failed for %s: %w\", addr, err)\n}","preventionTips":["Treat 'preparing attribute values' as a wrapper — always read the %w cause.","Upgrade Terraform Core/provider when the inner cause is an unsupported mark.","Keep state backups so a single unserializable value does not block all operations."],"tags":["terraform","jsonstate","serialization","wrapped-error","state"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}