Skip to content

fix(schema): iterating a Schema yields keys that __getitem__ refuses, so dict(schema) and .items() raise KeyError #1291

Closed

Description

@JarryShaw

Describe the bug
Schema.__iter__ (schema.py:622-626) yields every non-builtin attribute, including ones post_process sets that are not declared fields, while __getitem__ (:628-632) only serves __fields__ and falls through to super().__getitem__. Same for QuickStartRequestOption and the MPTCP option schemas.

To Reproduce

t = TSOption.unpack(bytes.fromhex("4408090000000001"), 8, None)   # pcapkit.protocols.schema.internet.ipv4
list(t)   # [..., "remainder", "data", "ts_flag", "timestamp"]
dict(t)   # KeyError

t["data"], t["ts_flag"], t["timestamp"] each raise KeyError.

Repro: /tmp/rtissues/corekit-repro.py (check D5) on origin/main 11ae68e.

Expected behavior
Every key yielded by __iter__ is readable through __getitem__ (or __iter__ only yields declared fields).

Found by the corekit round-trip audit (#1202). The repro was re-checked by an independent verifier, and I re-ran it on main at 11ae68ebf.

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 7, 2026
  2. JarryShaw commented on Oct 7, 2026

    @JarryShaw
    OwnerAuthor

    Blocked until the core schema PR for #1274/#1275/#1265/#1285 merges, because both edit protocols/schema/schema.py.

  3. added
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 7, 2026
  4. JarryShaw commented on Oct 7, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked: #1331 merged at 20:41Z. Back to pending.

  5. added
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 7, 2026
  6. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 8, 2026
  7. added this to the PyPCAPKit v1.5 milestone on Oct 25, 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