You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(corekit): registries' register accepts values their get rejects #1816
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.
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.
Activity
JarryShaw commentedon Oct 16, 2026
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.
JarryShaw commentedon Oct 16, 2026
#1792's PR is #1818; this stays blocked until #1818 merges.
JarryShaw commentedon Oct 16, 2026
See #1818 (comment) - we need to expand the scope to all enums.
JarryShaw commentedon Oct 16, 2026
Unblocked: #1818 has merged. Scope, per your note on #1818: every registry's
registerrejects what itsgetrejects, not justAppType. 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.fix(const): make every registry's register reject what its get rejects (
fix(const): make every registry's register reject what its get rejects (