Skip to content

Decode panics on nil interface with pre-populated typed pointer (upstream #304) #21

@xe-nvdk

Description

@xe-nvdk

Upstream: vmihailenco#304

When decoding a struct where an interface{} field was encoded as nil, but the decode target has that field pre-populated with a typed pointer (e.g., Data: &Recipe{}), the decoder panics with reflect.Value.Set using unaddressable value.

This is the canonical issue for a family of related panics:

Root cause is in ptrValueDecoder / decodeInterfaceValue — nil-handling path does not check v.CanSet().

Proposed fix (from upstream): Check for nil code in decodeInterfaceValue and use reflect.Zero to safely clear the value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Critical priorityupstream-bugBug inherited from upstream vmihailenco/msgpack

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions