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(protocols): a trial parse that raises and is kept as Raw still emits SchemaWarnings #2308
Describe the bug #1580 ruled that a trial next-layer parse replaced by Raw drops its warnings. That works only when _parse_next_layer does the replacing. When the trial parse raises, hold_warnings.__exit__ replays the held warnings, because it does so for any Exception "whatever discard says". _decode_next_layer then catches the error and keeps the layer as Raw. The warnings describe a layer the result does not contain.
Reproduction
frompcapkit.protocols.link.ethernetimportEthernet; e=Ethernet(bytes(6) +bytes(range(1, 7)) +b'\x08\x00'+bytes.fromhex('4500008c000100004011'))
type(e.payload).__name__# 'Raw', error='IPv4: header length 20 runs past the end of the data (10 octets)'
It also warns SchemaWarning: packet length < 0: -2, then -6, then -10.
Expected behavior
No SchemaWarnings, as #1580 ruled. The Raw's error already reports the cut header.
System information
Linux, CPython 3.14.9, pcapkit 1.5.0b14 at main9d504ead5.
Additional context
This conflicts with test_truncated_ipv4_header_warns_whatever_the_on_wire_length in tests/protocols/misc/pcap/test_frame_read_cap_len_2236_unit.py, and with the comment on it in Frame.read. Both pin this leak as the signal that a truncation was noticed (#2236). Options: (1) drop the held warnings when the trial parse raises and is replaced by Raw, and retarget the #2236 test to a signal that survives, such as the Raw's error; (2) keep the leak and narrow #1580's prose to "replaced by _parse_next_layer's length check".
Recommendation: option 1. It is what #1580 ruled, and the truncation stays visible through the Raw.
Activity
JarryShaw commentedon Oct 26, 2026
take recommendations
JarryShaw commentedon Oct 26, 2026
Ruling noted: taking the recommendation. A fix worker is on it; the PR will reference this issue.
fix(protocols): drop the warnings of a trial parse that is kept as Raw (
JarryShaw commentedon Oct 27, 2026
Ruling noted: keep
_beholdingprivate, as the_rebuildingprecedent recommended. No rename needed.