#35903 contrib: fix crash in message-capture-parser.py on non-printable msgtype
https://github.com/bitcoin/bitcoin/pull/35903 · · +2/-4 in 1 files, 1 commits · labels: Scripts and tools
Goal
- Prevent message capture parser crashes when encountering unprintable message types
- Ensure developers analyzing network traffic can parse full capture files without losing output
Fixes an unhandled TypeError crash in `contrib/message-capture/message-capture-parser.py` when encountering unprintable message types in capture files. The script previously called `raise UnicodeDecodeError` with no arguments inside a try block expecting 5 constructor arguments. The patch replaces the flawed exception raise with an inline printability check, falling back to labeling the message type as "UNREADABLE".
Problem: When parsing a message capture file containing non-printable message types, `message-capture-parser.py` crashes on a TypeError before writing any output. Developers analyzing p2p traffic lose the entire parse of a capture file if a single message has an unprintable type.
Category: Tools and scripts (#13 of 22)
P4 · bug fix
- P4 because message capture parsing is a niche developer script with low overall usage
- Fixes a genuine script crash but only impacts developers inspecting traffic captures
P4 because `message-capture-parser.py` is a niche developer script, and tooling priorities rank single-user and niche contrib scripts lowest. The patch fixes a genuine TypeError bug where `raise UnicodeDecodeError` was called without parameters.
Membership: Modifies `contrib/message-capture/message-capture-parser.py`, a developer helper script under contrib.
Factors: security/stability 0, bug 1, performance 0, user value 1, leverage 0
Reviewability: Ready
- Ready to review because the change is tiny and CI passes
The change is tiny, CI is green, and no code changes are pending.
Author status: silent since opening PR on 2026-08-05
Open concerns:
- sedited questioned whether the bug is still reachable after #35958 aligned v2 message validation with v1 range
Agreement: Crickets
- No formal reviews or approvals yet
- Questioned whether the crash remains reachable after recent message validation changes (sedited)
No reviews yet; sedited asked whether the crash remains reachable after #35958
No reviewer has reviewed or ACKed the PR. A single clarifying question on applicability was asked without an evaluation of the patch.
- sedited: 'Is this still relevant after #35958?'
Review verdicts (DrahtBot): 0
Files
6 lines under test/bench/ci.
- contrib/message-capture/message-capture-parser.py +2/-4
Card
This PR fixes a crash in `contrib/message-capture/message-capture-parser.py` when handling non-printable message types. The script previously attempted to raise `UnicodeDecodeError` without constructor arguments, triggering an unhandled `TypeError` that aborts the parse and discards all output. The change replaces the raise with a safe inline printability fallback to label the message type as UNREADABLE. It addresses a narrow bug in a niche diagnostic script under contrib and has received no reviews beyond a question regarding whether #35958 makes the condition unreachable.