{"record":{"id":"ed5db09e8d3296ff","repo":"temporalio/temporal","slug":"failed-to-deserialize-data-w","errorCode":null,"errorMessage":"failed to deserialize data: %w","messagePattern":"failed to deserialize data: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chasm/tree.go","lineNumber":648,"sourceCode":"\treturn nil\n}\n\nfunc (n *Node) prepareDataValue(\n\tchasmContext Context,\n\tvalueT reflect.Type,\n) error {\n\tmetadata := n.serializedNode.Metadata\n\tdataAttr := metadata.GetDataAttributes()\n\tif dataAttr == nil {\n\t\treturn softassert.UnexpectedInternalErr(\n\t\t\tn.logger,\n\t\t\t\"expect chasm node to have DataAttributes\",\n\t\t\tfmt.Errorf(\"actual attributes: %v\", metadata.Attributes))\n\t}\n\n\tif n.valueState == valueStateNeedDeserialize {\n\t\tif err := n.deserialize(valueT); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to deserialize data: %w\", err)\n\t\t}\n\t}\n\n\t// For now, we assume if a node is accessed with a MutableContext,\n\t// its value will be mutated and no longer in sync with the serializedNode.\n\t_, componentCanBeMutated := chasmContext.(MutableContext)\n\tif componentCanBeMutated {\n\t\tn.setValueState(valueStateNeedSerialize)\n\t}\n\n\treturn nil\n}\n\nfunc (n *Node) preparePointerValue() error {\n\tmetadata := n.serializedNode.Metadata\n\tpointerAttr := metadata.GetPointerAttributes()\n\tif pointerAttr == nil {\n\t\treturn softassert.UnexpectedInternalErr(","sourceCodeStart":630,"sourceCodeEnd":666,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/chasm/tree.go#L630-L666","documentation":"prepareDataValue in chasm/tree.go lazily deserializes a data node's stored payload into valueT when valueState is valueStateNeedDeserialize. On failure the error is wrapped with 'failed to deserialize data'. This means the node's DataAttributes payload cannot be decoded into the expected Go value type.","triggerScenarios":"Reading a CHASM data node value (via a Context accessor) after the node was loaded from persistence in need-of-deserialize state and n.deserialize(valueT) fails — typically because the persisted bytes do not match the requested type or are corrupt.","commonSituations":"Requesting a data value with the wrong generic type parameter (schema drift between writer and reader), changing a data field's type without migration, or corrupted node payloads after failed writes.","solutions":["Confirm the type used to read the data node matches the type used when it was written","Check for schema/type changes since the data was persisted and add backward compatibility","Inspect the stored payload for the failing node to verify it is intact and non-empty","Re-write or delete the offending node data if it is confirmed corrupt"],"exampleFix":"// before\nvar out map[string]int\nchasmCtx.GetValue(node) // node was written as map[string]string\n// after\nvar out map[string]string\nval := chasmCtx.GetValue(node)\nconverted := map[string]int{}\nfor k, v := range val { converted[k] = len(v) }","handlingStrategy":"validation","validationCode":"// Ensure the read type matches the write type before calling accessors:\nvar expect map[string]string\n_ = expect // use the same generic type the node was written with","typeGuard":"func dataMatches[T any](want T, meta NodeMetadata) bool { /* compare metadata's registered value type against reflect.TypeOf(want) */ return reflect.TypeOf(want).String() == meta.ValueTypeName }","tryCatchPattern":"v := chasmCtx.GetData(myNode)\n// deserialization errors surface here; wrap access in a helper:\nfunc safeGet[T any](c chasm.Context, n Node) (T, error) {\n  var out T\n  if err := c.GetValueInto(n, &out); err != nil {\n    return out, fmt.Errorf(\"read data node: %w\", err)\n  }\n  return out, nil\n}","preventionTips":["Use a single shared Go type definition for reading and writing a data node","Avoid changing data field types; add new fields instead","Version data payloads if the shape must evolve","Validate round-trip serialize/deserialize in unit tests"],"tags":["go","chasm","deserialization","persistence"],"backgroundTag":"deserialization-failed","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}