Skip to content

fix(foundation): Deferred.__init__'s proto type is too narrow for transport-keyed reassembly #2417

Closed

Description

@JarryShaw

Describe the bug

Deferred.__init__ (pcapkit/foundation/reassembly/data/data.py) types its proto parameter as 'TransType' and documents it as "Payload protocol type", but TCP.submit (pcapkit/foundation/reassembly/tcp.py) passes a port pair ((bufid[1], bufid[3])), not a TransType — because Transport.analyze overrides Protocol.analyze(proto: int, ...) to analyze(ports: tuple[int, int], ...).

At runtime, Deferred.proto for a TCP reassembly holds a tuple like (12345, 443), not a TransType member. The IP reassembler is the only caller that actually passes a real TransType.

To Reproduce

mypy independently flags the call site:

Argument 2 to "Deferred" has incompatible type "tuple[Any, Any]"; expected "TransType"

in TCP.submit.

Expected behavior

Widen Deferred.__init__'s proto annotation (and docstring) to cover both cases — e.g. 'TransType | tuple[int, int]' — or introduce a narrower per-reassembler type if the class is meant to be specialized per transport.

Additional context

Found and verified during this session's #1103 prose sweep (a real type/behavior gap, out of that sweep's prose-only scope). Behavior itself is fine; only the annotation and docstring are wrong for the TCP/transport-keyed case.

Activity

  1. added
    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 28, 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 28, 2026
  3. moved this to Pending in PyPCAPKiton Oct 28, 2026
  4. added this to the PyPCAPKit v1.5 milestone on Oct 28, 2026
  5. moved this from Pending to WIP in PyPCAPKiton Oct 28, 2026
  6. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 28, 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

    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions