Skip to content

Avoid decoding errors when extracting message ID from stdin

Kyle Meyer tools 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2Avoid decoding errors when extracting message ID from stdinb4/__init__.py b4/pr.py+2 -20 replies
2/2Parse just headers when extracting message ID from stdin mboxb4/__init__.py b4/pr.py+7 -21 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH b4 0/2] Avoid decoding errors when extracting message ID from stdin
Quoted 21 lines · Michael S. Tsirkin
Quoted 14 lines · Kyle Meyer
Quoted 12 lines · Michael S. Tsirkin

Passing message id [email protected] to b4 gives this backtrace:

Traceback (most recent call last):
[....]
File "/scm/b4/b4/__init__.py", line 2072, in get_msgid_from_stdin
message = email.message_from_string(sys.stdin.read())
File "/usr/lib64/python3.9/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd4 in position 5886: invalid continuation byte

Quoted 5 lines
Quoted 1 line

mutt does not seem to have trouble decoding this ... weird.

I'm confused by that backtrace. I think get_msgid_from_stdin() should be called only when a message is fed on stdin. You say you're passing a message ID. That's as a positional argument, right?

Quoted 6 lines

Sorry. I passed the message on the stdin. I supplied the message ID so you can get the original from the list archives.

To reproduce:

wget -O - https://lore.kernel.org/lkml/[email protected]/raw | b4 mbox

Thanks. I can trigger that on my end too. Here's a possible fix. The first patch is the actual fix. The second patch makes this code path do a little less work but isn't necessary.

[1/2] Avoid decoding errors when extracting message ID from stdin [2/2] Parse just headers when extracting message ID from stdin mbox

 b4/__init__.py | 4 +++-
 b4/pr.py       | 5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

base-commit: 06cc7c8820aea85d1329911b785d7bf4ecaacb1f

Signature · 1 line
2.32.0