Describe the bug
AppType.get has three defects on the same code path. The second silently returns wrong data.
>>> AppType.get('http')
TypeError: 'http' already in use as <AppType.http: 80 [tcp|udp|sctp]>
>>> AppType.get('ssh')
<AppType.ssh: -1 [undefined]> # real ssh port is 22; enum grew 8182 -> 8183
>>> AppType.get(999999, proto='tcp')
unknown [999999 - tcp] # ports are 16-bit
Root cause, pcapkit/const/reg/apptype.py:30620 — the string path tests key in AppType.__members_proto__, but that dict is keyed by TransportProtocol, so a str key never matches. It almost certainly meant AppType.__members__. Every name lookup therefore falls through to the mint branch:
- name already a member →
extend_enum raises TypeError: already in use
- name not a member → mints a new member with
port=-1, returns it, and permanently grows the enum
Separately, the same except ValueError wrapper swallows the guard that should reject out-of-range ports, so get(999999) mints instead of raising.
Expected behavior
get('http') returns the existing member. get('ssh') returns port 22. get(999999) raises, as every other registry does for an out-of-range code (see tests/const/test_const_enum_builtin_parity.py, issue #647).
Additional context
AppType is generated. The fix belongs in the template at pcapkit/vendor/reg/apptype.py and the generated pcapkit/const/reg/apptype.py, kept in lockstep — test_const_enum_builtin_parity.py lists pcapkit.vendor.reg.apptype in BESPOKE_TEMPLATES and renders the template to compare it character-for-character against the generated module. The crawler hits live IANA endpoints, so it cannot be re-run in CI.
Independent of #732, which would restructure these files: the #732 plan puts this fix first precisely because it carries no design dependency. Worth fixing once here rather than replicating into N classes later.
Describe the bug
AppType.gethas three defects on the same code path. The second silently returns wrong data.Root cause,
pcapkit/const/reg/apptype.py:30620— the string path testskey in AppType.__members_proto__, but that dict is keyed byTransportProtocol, so astrkey never matches. It almost certainly meantAppType.__members__. Every name lookup therefore falls through to the mint branch:extend_enumraisesTypeError: already in useport=-1, returns it, and permanently grows the enumSeparately, the same
except ValueErrorwrapper swallows the guard that should reject out-of-range ports, soget(999999)mints instead of raising.Expected behavior
get('http')returns the existing member.get('ssh')returns port 22.get(999999)raises, as every other registry does for an out-of-range code (seetests/const/test_const_enum_builtin_parity.py, issue #647).Additional context
AppTypeis generated. The fix belongs in the template atpcapkit/vendor/reg/apptype.pyand the generatedpcapkit/const/reg/apptype.py, kept in lockstep —test_const_enum_builtin_parity.pylistspcapkit.vendor.reg.apptypeinBESPOKE_TEMPLATESand renders the template to compare it character-for-character against the generated module. The crawler hits live IANA endpoints, so it cannot be re-run in CI.Independent of #732, which would restructure these files: the #732 plan puts this fix first precisely because it carries no design dependency. Worth fixing once here rather than replicating into N classes later.