Skip to content

fix(protocols): from_data(info.to_dict()) drops the payload because to_dict omits __next_type__/__next_name__ #1447

Closed

Description

@JarryShaw

Bug. Cls.from_data(layer.info.to_dict()) drops the payload. Info.to_dict() omits __next_type__ and __next_name__, which _make_payload dispatches on (pcapkit/protocols/protocol.py:1926). IPv6 also loses its extension headers, because __exthdr__ is dropped as well (ipv6.py:367).

Repro on main (78991b7d5), examples/captures/ipv4.pcap frame 1:

Ethernet.from_data(eth.info.to_dict()).data   # 14 of 1870 octets
  • Layers affected: Frame, Ethernet, ARP, IPv4, IPv6, TCP and UDP, whenever the layer carries a payload.
  • HTTP: always raises ProtocolError('invalid HTTP data: Raw').
  • Equality: Info.from_dict(to_dict()) == info still holds, because the comparison ignores those keys.

Found by #1445 (#1202), where it is listed in DICT_GAPS.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 9, 2026
  2. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 9, 2026
  3. JarryShaw commented on Oct 9, 2026

    @JarryShaw
    OwnerAuthor

    A worker is on it now, on branch fix/1447-to-dict-payload-roundtrip.

  4. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 9, 2026
  5. added this to the PyPCAPKit v1.5 milestone on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixPull requests that fix a defect (fix: subject prefix)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions