Roundup Tracker - Issues

Issue 2550667

classification
Problem with multi-part messages
Type: crash Severity: urgent
Components: Mail interface Versions: 1.4
process
Status: closed fixed
:
: schlatterbeck : benni, schlatterbeck
Priority: normal : patch

Created on 2010-08-23 08:12 by benni, last changed 2010-10-05 14:25 by schlatterbeck.

Files
File name Uploaded Description Edit Remove
roundup-failed-test-multipart benni, 2010-08-23 08:12 the mail which caused the error
roundup-error benni, 2010-08-23 08:13 logfile
mailgw.patch schlatterbeck, 2010-09-08 10:17 patch mail gateway to send out traceback
Messages
msg4121 Author: [hidden] (benni) Date: 2010-08-23 08:12
If i send a multi-part-message to the mailgw, i just got an error back:

---------------------------------------------------------------
Es gab ein Problem mit Ihrer Nachricht:
   Expected list, got <type 'str'>



Mail Gateway Help
=================
Incoming messages are examined for multiple parts:
 . In a multipart/mixed message or part, each subpart is extracted and
   examined. The text/plain subparts are assembled to form the textual
   body of the message, to be stored in the file associated with a "msg"
   class node. Any parts of other types are each stored in separate files
   and given "file" class nodes that are linked to the "msg" node.
 . In a multipart/alternative message or part, we look for a text/plain
   subpart and ignore the other parts.

[... and much more from the documentation...]

------------------------------------------------------------

Attached is the output from log during mailgw-run and the mail itself.
The error could be reproduced if you forward mail with "embedded" option
in thunderbird 3.x.

My roundup-version is:

root@attac-mailman:~# roundup-admin -v
1.4.15 (python 2.5.2)

Thanks for any hint!

regards, Benni
msg4122 Author: [hidden] (benni) Date: 2010-08-23 08:13
the log from mailgw
msg4123 Author: [hidden] (schlatterbeck) Date: 2010-08-23 08:40
On Mon, Aug 23, 2010 at 08:12:58AM +0000, Benni Bärmann wrote:
> 
> New submission from Benni Bärmann <benni@attac.de>:
> 
> If i send a multi-part-message to the mailgw, i just got an error back:
> 
> ---------------------------------------------------------------
> Es gab ein Problem mit Ihrer Nachricht:
>    Expected list, got <type 'str'>

Did you do any changes to your roundup installation?
This looks to me like you changed/added a detector that now throws an
AttributeError exception with the error message you've given.

For historical reasons, roundup treats AttributeError in a detector like
a Reject -- in the early days there was no separate Reject Exception in
detectors. (Richard: Maybe we should fix this, it's hard to debug detector
errors... and I don't think there are many old detectors out there now)

You might want to look around line 1387 of roundup/mailgw.py and print
out the full exception there to debug the problem. Please let us know if
the problem was in your own code or if it turns out to be a problem in
roundup core. In the latter case, please attach the full traceback.
You can print it by calling format_exc from the traceback module, e.g.
(completely untested):

at to of file:
from traceback import format_exc

around line 1387:
        except (TypeError, IndexError, ValueError, exceptions.Reject), message:
            exc = format_exc ()
            raise MailUsageError, _("""
There was a problem with the message you sent:
   %(message)s\n%(exc)s
""") % locals()

Thanks, Ralf
msg4124 Author: [hidden] (benni) Date: 2010-08-24 09:24
Hi Ralf,

I removed my own detector and got still the same error. After that i
tried your code, but got no reaction at all (no error, no log). Than i
removed all detectors and got the same.

Any hints what to try next?

Regards, Benni
msg4125 Author: [hidden] (schlatterbeck) Date: 2010-08-24 18:21
Benni,
can you provide the message you are sending to roundup -- if possible
with all headers and mime formatting intact. That way it's easier for me
to test this. You may want to strip the message from any confidential
information it may have (but please verify that you're still seeing the
problem).
You should restore the mailgw.py to its original state before trying my
modification. I'll test my own modification now -- preferrably with your
message.

Thanks, Ralf
msg4126 Author: [hidden] (benni) Date: 2010-08-30 09:25
Hi Ralf,

the message with all headers was attached in the original issue. Did I
miss something with this message?

Sorry for answering late, i was sick last week.

Regards, Benni
msg4127 Author: [hidden] (schlatterbeck) Date: 2010-09-08 10:17
I've looked a little closer into this.
Attached is the patch to mailgw that sends the traceback in addition to
the mail problem report -- just if you want to debug this yourself.

The problem is in roundup core and is related to parsing of
message/rfc822 attachments -- when sending out the result of such a
message we generate a binary (base64 encoded) attachment and manually
set the mime type to message/rfc822. The serialisation of the email
module expects a list for this mime type and crashes.

Now this raises the question of how to handle message/rfc822 attachments:
- just attach the thing as binary encoded message -- will not be of
  much use to a user of the web interface, but maybe we can come up
  with a creative way of handling message/rfc822 at the browser side
- look into the message and parse the parts contained in it, attach
  these parts to the issue. Downside: Relation to the original email
  attachment gets lost but we have this problem anyway with deeply
  nested attachment structures (e.g. multipart/mixed).

Does it often happen in your environment that you send mails to roundup
which contain an email attachment?

For Reference the traceback, note that this happens in the nosyreactor
when we want to *send out* the email attachment we received:

Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/roundup/mailgw.py", line
1377, in _handle_message
    cl.set(nodeid, **props)
  File
"/usr/local/lib/python2.5/site-packages/roundup/backends/rdbms_common.py",
line 1602, in set
    self.fireReactors('set', nodeid, oldvalues)
  File "/usr/local/lib/python2.5/site-packages/roundup/hyperdb.py", line
1230, in fireReactors
    react(self.db, self, nodeid, oldvalues)
  File "./detectors/nosyreaction.py", line 56, in nosyreaction
    cl.nosymessage(nodeid, msgid, oldvalues)
  File "/usr/local/lib/python2.5/site-packages/roundup/roundupdb.py",
line 286, in nosymessage
    bcc_sendto)
  File "/usr/local/lib/python2.5/site-packages/roundup/roundupdb.py",
line 513, in send_message
    mailer.smtp_send(sendto + bcc_sendto, message.as_string())
  File "/usr/lib/python2.5/email/message.py", line 131, in as_string
    g.flatten(self, unixfrom=unixfrom)
  File "/usr/lib/python2.5/email/generator.py", line 84, in flatten
    self._write(msg)
  File "/usr/lib/python2.5/email/generator.py", line 109, in _write
    self._dispatch(msg)
  File "/usr/lib/python2.5/email/generator.py", line 135, in _dispatch
    meth(msg)
  File "/usr/lib/python2.5/email/generator.py", line 201, in
_handle_multipart
    g.flatten(part, unixfrom=False)
  File "/usr/lib/python2.5/email/generator.py", line 84, in flatten
    self._write(msg)
  File "/usr/lib/python2.5/email/generator.py", line 109, in _write
    self._dispatch(msg)
  File "/usr/lib/python2.5/email/generator.py", line 135, in _dispatch
    meth(msg)
  File "/usr/lib/python2.5/email/generator.py", line 266, in _handle_message
    g.flatten(msg.get_payload(0), unixfrom=False)
  File "/usr/lib/python2.5/email/message.py", line 185, in get_payload
    raise TypeError('Expected list, got %s' % type(self._payload))
TypeError: Expected list, got <type 'str'>
msg4138 Author: [hidden] (schlatterbeck) Date: 2010-10-05 14:25
fixed in r4530
History
Date User Action Args
2010-10-05 14:25:36schlatterbecksetstatus: open -> closed
resolution: fixed
messages: + msg4138
2010-09-08 10:17:34schlatterbecksetfiles: + mailgw.patch
keywords: + patch
messages: + msg4127
2010-08-30 09:25:58bennisetmessages: + msg4126
2010-08-24 18:21:35schlatterbecksetstatus: new -> open
assignee: schlatterbeck
messages: + msg4125
components: + Mail interface
priority: normal
2010-08-24 09:24:25bennisetmessages: + msg4124
2010-08-23 08:40:59schlatterbecksetnosy: + schlatterbeck
messages: + msg4123
2010-08-23 08:13:43bennisetfiles: + roundup-error
messages: + msg4122
2010-08-23 08:12:57bennicreate