{"record":{"id":"7df118f9537ccb62","repo":"temporalio/temporal","slug":"w-cannot-deserialize-into-v","errorCode":null,"errorMessage":"%w: cannot deserialize into %v","messagePattern":"%w: cannot deserialize into (.+?)","errorType":"validation","errorClass":"serializer error","httpStatus":null,"severity":"error","filePath":"common/nexus/payload_serializer.go","lineNumber":23,"sourceCode":"\t\"fmt\"\n\t\"maps\"\n\t\"mime\"\n\n\t\"github.com/nexus-rpc/sdk-go/nexus\"\n\tcommonpb \"go.temporal.io/api/common/v1\"\n\tenumspb \"go.temporal.io/api/enums/v1\"\n\t\"go.temporal.io/server/common/persistence/serialization\"\n)\n\ntype payloadSerializer struct{}\n\nvar errSerializer = errors.New(\"serializer error\")\n\n// Deserialize implements nexus.Serializer.\nfunc (payloadSerializer) Deserialize(content *nexus.Content, v any) error {\n\tpayloadRef, ok := v.(**commonpb.Payload)\n\tif !ok {\n\t\treturn fmt.Errorf(\"%w: cannot deserialize into %v\", errSerializer, v)\n\t}\n\n\tpayload := &commonpb.Payload{}\n\t*payloadRef = payload\n\tpayload.Metadata = make(map[string][]byte)\n\tpayload.Data = content.Data\n\n\th := maps.Clone(content.Header)\n\t// We assume that encoding is handled by the transport layer and the content is decoded.\n\tdelete(h, \"encoding\")\n\t// Length can safely be ignored.\n\tdelete(h, \"length\")\n\n\tif len(h) > 1 {\n\t\tsetUnknownNexusContent(h, payload.Metadata)\n\t\treturn nil\n\t}\n","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/nexus/payload_serializer.go#L5-L41","documentation":"The Temporal payloadSerializer implements nexus.Serializer and only accepts a **commonpb.Payload as the Deserialize output target, because it converts Nexus Content into Temporal payloads. Passing any other pointer type (e.g. **nexus.Content for a different serializer contract, or a struct pointer) is a type mismatch and returns this wrapped errSerializer.","triggerScenarios":"Calling payloadSerializer.Deserialize(content, v) where v is not **commonpb.Payload — e.g. passing *string, **struct, or a *nexus.Content target — typically from the anonymous handler plumbing that deserializes Nexus operation inputs.","commonSituations":"Mixing serializers: using the Temporal payload serializer with handlers written for the default nexus.Serializer (or vice versa); misconfigured Server options that install the wrong serializer; hand-written test code calling Deserialize with the wrong target type.","solutions":["Pass a **commonpb.Payload as the output parameter when using the Temporal payload serializer.","Check which Serializer is registered in nexus HandlerServerOptions and use the matching input/output types in handlers.","If handlers should use plain Go types, use the default nexus.Serializer instead of the Temporal one.","Inspect the wrapping error's %v suffix — it prints the actual value passed — to spot the type mismatch."],"exampleFix":"// before\nvar out string\nerr := serializer.Deserialize(content, &out) // not **commonpb.Payload\n// after\nvar payload *commonpb.Payload\nerr := serializer.Deserialize(content, &payload)","handlingStrategy":"type-guard","validationCode":"func canDeserializeWithTemporalSerializer(v any) bool {\n    _, ok := v.(**commonpb.Payload)\n    return ok\n}","typeGuard":"func deserializePayload(content *nexus.Content) (*commonpb.Payload, error) {\n    var p *commonpb.Payload\n    if err := payloadSerializer{}.Deserialize(content, &p); err != nil {\n        return nil, err\n    }\n    return p, nil\n}","tryCatchPattern":"var payload *commonpb.Payload\nif err := serializer.Deserialize(content, &payload); err != nil {\n    return nil, fmt.Errorf(\"nexus input is not a temporal payload: %w\", err)\n}","preventionTips":["Only pass **commonpb.Payload targets to the Temporal payload serializer","Check which Serializer is set in HandlerServerOptions before writing handler signatures","Use the default nexus.Serializer for arbitrary Go types","Add one round-trip Serialize/Deserialize test per serializer configuration"],"tags":["nexus","serialization","type-mismatch","temporal-payload"],"backgroundTag":"serializer-type-mismatch","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}