{"record":{"id":"d54241dbd0fd1837","repo":"hashicorp/terraform","slug":"s-cannot-serialize-value-marked-as-v-for-inclu","errorCode":null,"errorMessage":"%s: cannot serialize value marked as %#v for inclusion in a state snapshot (this is a bug in Terraform)","messagePattern":"(.+?): cannot serialize value marked as %#v for inclusion in a state snapshot \\(this is a bug in Terraform\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/jsonstate/state.go","lineNumber":624,"sourceCode":"\t\tpanic(fmt.Sprintf(\"sensitiveAsBool cannot handle %#v\", val))\n\t}\n}\n\n// unmarkValueForMarshaling takes a value that possibly contains marked values\n// and returns an equal value without markings along with the separated mark\n// metadata that should be presented alongside the value in another JSON\n// property.\n//\n// This function only accepts the marks that are valid to persist, and so will\n// return an error if other marks are present. Marks that this package doesn't\n// know how to store must be dealt with somehow by a caller -- presumably by\n// replacing each marked value with some sort of storage placeholder.\nfunc unmarkValueForMarshaling(v cty.Value) (unmarkedV cty.Value, sensitivePaths []cty.Path, err error) {\n\tval, pvms := v.UnmarkDeepWithPaths()\n\tsensitivePaths, otherMarks := marks.PathsWithMark(pvms, marks.Sensitive)\n\t_, otherMarks = marks.PathsWithMark(otherMarks, marks.Deprecation)\n\tif len(otherMarks) != 0 {\n\t\treturn cty.NilVal, nil, fmt.Errorf(\n\t\t\t\"%s: cannot serialize value marked as %#v for inclusion in a state snapshot (this is a bug in Terraform)\",\n\t\t\ttfdiags.FormatCtyPath(otherMarks[0].Path), otherMarks[0].Marks,\n\t\t)\n\t}\n\treturn val, sensitivePaths, err\n}\n","sourceCodeStart":606,"sourceCodeEnd":631,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/jsonstate/state.go#L606-L631","documentation":"Thrown by unmarkValueForMarshaling when a cty value in state carries a mark other than the two that Terraform knows how to persist (marks.Sensitive and marks.Deprecation). The message explicitly states this is a bug in Terraform: only those two marks are serializable, and any other mark indicates an internal subsystem wrote a non-persistable mark into state.","triggerScenarios":"Raised when, after unmarking, marks.PathsWithMark finds remaining marks that are neither Sensitive nor Deprecation. The first offending path and mark set are reported. Surfaced indirectly via the 'preparing attribute values' wrappers (628/630) during JSON state rendering.","commonSituations":"Almost always an internal Terraform/provider bug — a subsystem introduced a new cty mark (e.g. for ephemeral values, ephemeral-as-mark, or a custom provider mark) that the state serializer cannot handle. Seen in prerelease builds or when a provider SDK adds a mark type Terraform Core does not yet whitelist for persistence.","solutions":["Upgrade Terraform Core to a release that knows how to persist the mark (or that stops emitting it into state).","Upgrade the provider whose SDK introduced the unsupported mark.","Report the bug to hashicorp/terraform with the state file and provider versions; the message itself flags it as a Terraform bug.","Workaround: re-apply the affected resource so a fresh value without the rogue mark is written to state."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before marshaling, assert no value carries marks outside the persistable set.\n_, _, other := marksPersistable(v)\nif len(other) != 0 {\n    return fmt.Errorf(\"internal bug: value has non-persistable mark %#v\", other[0].Marks)\n}","typeGuard":null,"tryCatchPattern":"if _, _, err := jsonstate.UnmarkValueForMarshaling(v); err != nil {\n    // Explicit Terraform bug — report upstream and re-apply the resource to clear the rogue mark.\n    return err\n}","preventionTips":["Only ever write marks.Sensitive or marks.Deprecation into values destined for state.","When adding a new cty mark type, update unmarkValueForMarshaling's allowlist first.","Upgrade Terraform Core and providers together so mark sets stay in sync."],"tags":["terraform","jsonstate","cty-marks","internal-bug","serialization"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}