Skip to content

refactor(protocols): keep a handled next-layer refusal quiet - #2597

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/2588-quiet-refusal
Nov 2, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/2588-quiet-refusal

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • refactor — changes neither behaviour nor performance

Description of your pull request and other information

This implements the owner's option 2 on #2588, with sub-question 1: when the next-layer fallback refuses a layer and keeps it as Raw, the refusal is now quiet.

  • The change: beholder runs the next-layer call inside CaughtByCaller(ProtocolError). A ProtocolError it absorbs logs nothing, skips the old WARNING, and installs neither sys.excepthook nor threading.excepthook. The error is still recorded on the Raw layer's info.error.
  • Scope: the block covers the whole call, at any depth. An inner CaughtByCaller() keeps its own error loud, and so does every other BaseError the fallback absorbs, such as FieldValueError. Building a layer directly still raises loudly, and so does the outermost recovery error.
  • Docs: a "Handled Refusals" section on protocol-family-grouping.rst records the rule.

Measured: across 50,164 inputs, main and this branch produce identical chains, info, info.error, rebuilt octets, warnings and raises. CRITICAL records drop from 44,146 to 1,150. The new tests fail on main. Two IPv6 tests now pin the error text and a single parse instead of log records; a mutation check confirms they still catch a double parse.

Left loud, as follow-ups: ProtocolBase.analyze and Transport.analyze substitute Raw without recording the error, and pypcapfile's trial parses record nothing. Quieting them first needs the error recorded.

Closes #2588

- beholder runs the decorated call inside CaughtByCaller(ProtocolError), so
  every ProtocolError built during it is quiet and a refusal kept as Raw logs
  nothing and installs neither excepthook; beholder skips its WARNING for that
  class. Other classes, and the outermost recovery, stay loud.
- Record the rule on protocol-family-grouping.rst and the exceptions page;
  update beholder's docstring, IPv6's walk comment and the pcapng generator's
  logging notes.
- tests: new protocol and beholder cases, nested recovery included; the IPv6
  #2477 tests count parses and pin the error text instead of loud records.
@JarryShaw JarryShaw added refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 1, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 4c4d2e7be. A Sonnet review and two delta checks passed, and I checked the final prose diff myself. Over 50,164 inputs, behaviour is identical apart from the logs and hooks. Every scope probe holds: an inner CaughtByCaller() stays loud, a generator or another thread stays loud, and the outermost recovery is loud while the inner ones are quiet. The class-keyed WARNING skip keeps the quiet EOF StructError's warning. The new tests fail on main, and the corekit leg (937 tests) is OK.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Coverage: 94.03% (unit tier, Python 3.15, 4c4d2e7be, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 20093 144 2712 125 98.78%
pcapkit/corekit 2607 74 820 37 96.53%
pcapkit/dumpkit 281 3 100 3 98.43%
pcapkit/foundation 3360 27 1186 32 98.70%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 20346 220 5370 204 98.34%
pcapkit/toolkit 961 28 342 10 96.32%
pcapkit/utilities 506 7 144 5 98.15%
pcapkit/vendor 5009 2222 1148 182 52.31%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 930606a into main Nov 2, 2026
67 checks passed
@JarryShaw
JarryShaw deleted the refactor/2588-quiet-refusal branch November 2, 2026 02:19
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 2, 2026
@github-actions github-actions Bot added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 2, 2026
JarryShaw added a commit that referenced this pull request Nov 2, 2026
…1.6.0 (#2449)

- Added: DCCP, its checksum over the IP pseudo-header, register_dccp and
  register_dccp_option, and the pcapkit.const.dccp registries (#2593).
- Folded into unreleased entries: LinuxSLL's stop on its ARPHRD path
  (#2587) and ARPHRD's __proto_dest__ (#2598), SSLv2 records chained in a
  segment (#2585), the checksum's move to pcapkit.corekit.checksum.internet
  (#2586), and IGMPv2's and IGMPv3's versioned name (#2590).
- Breaking: InARP moves to pcapkit.protocols.link.inarp with no re-export,
  joining the DRARP entry (#2596).
- Changed: the conventions' new rulings (#2599), the milestone workflow's
  next-open-milestone lookup (#2591), the PyPy protocols shards (#2604).
  Fixed: a handled next-layer refusal is quiet under beholder (#2597); the
  IPX crawlers restore sys.path (#2601).
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

refactor(protocols): a next-layer refusal that falls back to Raw still logs at CRITICAL and installs sys.excepthook

1 participant