Skip to content

fix(corekit): registries' register accepts values their get rejects #1816

Closed

Description

@JarryShaw

Describe the bug
EnumRegistry.register calls the _validate_value hook (pcapkit/corekit/enum.py), but no generated registry overrides it, so the hook accepts everything. Most registries range-check only in _missing_, which means register mints a value that get would reject. Afterwards get returns the minted member. For example, Hardware.register(70000, 'zz') mints, and Hardware.get(70000) then returns it. OptionType.register(70000, 'opt_x') does the same, although _missing_ rejects anything above 0xFFFF.

#1792 fixes this for AppType only, by giving it a _validate_value override.

Expected behavior
Every registry's register rejects what its get rejects. The fix most likely belongs in the vendor generators: emit a _validate_value override (raising EnumValueError, per registry-protocol.rst) from the same range check each generator already writes into _missing_, then regenerate. A test then checks, for every registry, that register and get agree on an out-of-range value.

Additional context
Found by #1792's worker and confirmed by its Sonnet review, which walked the EnumRegistry subclasses at runtime. No existing issue covers it.

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

    @JarryShaw
    OwnerAuthor

    Blocked until #1792's PR merges; it changes the AppType const file and template, and this fix changes the generators that emit every registry's file.

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

    @JarryShaw
    OwnerAuthor

    #1792's PR is #1818; this stays blocked until #1818 merges.

  5. moved this to Blocked in PyPCAPKiton Oct 16, 2026
  6. JarryShaw commented on Oct 16, 2026

    @JarryShaw
    OwnerAuthor

    See #1818 (comment) - we need to expand the scope to all enums.

  7. JarryShaw commented on Oct 16, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked: #1818 has merged. Scope, per your note on #1818: every registry's register rejects what its get rejects, not just AppType. That covers the generated registries through their vendor generators and the hand-written ones directly, with one test across all of them. A worker is on it.

  8. added
    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
    on Oct 16, 2026
  9. moved this from Blocked to WIP in PyPCAPKiton Oct 16, 2026
  10. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 16, 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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions