Skip to content

fix(foundation): a registrar given a non-enum code raises after registering it #2186

Closed

Description

@JarryShaw

What fails: the method-name registrars in pcapkit/foundation/registry/protocols.py register first and then log code.name. A code that is not an enum member (an int, None) therefore raises AttributeError after the protocol's registry has already been changed.

Repro on main 4c3d30163:

from pcapkit.foundation.registry.protocols import register_ipv4_option
from pcapkit.protocols.internet.ipv4 import IPv4
register_ipv4_option(250, 'lsr')   # AttributeError: 'int' object has no attribute 'name'
250 in IPv4.__option__              # True: the entry is left behind

Expected: a bad code is rejected with an in-library error before anything is registered, or the int is accepted and logged without .name. Either way, a failed call leaves the registry unchanged.

Scope: every registrar using the same logger.debug(..., code.name) after the register call. Only the IPv4 one is reproduced.

Test: for each registrar, a bad code raises without changing the registry.

Found by the cross-review of #2183.

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 25, 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 25, 2026
  3. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 25, 2026
  4. 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

    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