process-mail.py crashing with Unicode logging errors

Bug #847485 reported by William Grant
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Critical
Данило Шеган

Bug Description

process-mail.py is now sometimes crashing (maybe not enough to kill the whole script, not sure) with a UnicodeDecodeError:

Traceback (most recent call last):
  File "/usr/lib/python2.6/logging/__init__.py", line 791, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8e in position 43: ordinal not in range(128)

This was first noticed immediately after we switched it to use --log-file, but it was possibly just being redirected away before, so may not be new.

Regardless, it needs fixing as it's either an OOPS or is hiding one.

Tags: oops qa-ok

Related branches

Revision history for this message
William Grant (wgrant) wrote :

By comparing logs for various runs, I can see that the error is not fatal. It just causes one log message to disappear. That's this one:

    log.info(
        'Attempting DKIM authentication of message id=%s from=%s sender=%s'
        % (signed_message['Message-ID'],
            signed_message['From'],
            signed_message['Sender']))

Looks like From/Sender may be non-ASCII bytestrings, and logging is trying to encode them to UTF-8?

Revision history for this message
Robert Collins (lifeless) wrote :

This isn't hiding an OOPS, but it is causing poor signal-to-noise which is itself sufficient to be critical.

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 847485] Re: process-mail.py crashing with Unicode logging errors

Just changing the format string to %r would be an easy fix and the
logs would still be legible. Sorry for the noise.

> Looks like From/Sender may be non-ASCII bytestrings, and logging is trying to encode them to UTF-8?

It looks to me a bit more like it is trying to write unicode objects
to an ascii log stream, and it would be better off actually writing
them as utf-8. That might be worth fixing separately.

It seems like it's some kind of other bug that we get a truncated traceback.

Changed in launchpad:
assignee: nobody → Данило Шеган (danilo)
Changed in launchpad:
status: Triaged → In Progress
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
tags: added: qa-needstesting
Changed in launchpad:
status: In Progress → Fix Committed
William Grant (wgrant)
tags: added: qa-ok
removed: qa-needstesting
William Grant (wgrant)
Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.