Skip to content

fix(const): AppType.register and OptionType.register let an enclosing quiet block silence their rejection #1916

Closed

Description

@JarryShaw

EnumRegistry.register runs _validate_value inside with _CaughtByCaller(): (pcapkit/corekit/enum.py:580). That keeps its rejection loud even inside a quiet get block, which is what the #1845 ruling asked for. The generated overrides call cls._validate_value(...) without that block: pcapkit/const/reg/apptype/apptype.py:2831 and pcapkit/const/pcapng/option_type.py:280. Both come from the templates in pcapkit/vendor/reg/apptype/apptype.py and pcapkit/vendor/pcapng/option_type.py:190.

Repro on 95caa8b36, with a handler attached to the pcapkit logger. Inside with _CaughtByCaller(ValueError):, TCP.register(70000, 'x') and OptionType.register(-1, 'x') raise EnumValueError and log nothing. In the same block, an EnumRegistry subclass whose _validate_value rejects does log EnumValueError: .... Outside any block, all three log.

The AppType.register docstring says it validates "as EnumRegistry.register does", which is only partly true. The #1873 review noted this as a non-blocker, since nothing reaches these overrides from a quiet block today.

Fix: wrap both calls in with _CaughtByCaller(): in the vendor templates, regenerate the const modules, and add a loud-inside-quiet test for each override, mirroring #1873's register test.

Found in the #1103 round-4 sweep.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    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
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 19, 2026
  2. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 19, 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