Merge ubuntu-dev-tools:import-bug-fix into ubuntu-dev-tools:master

Proposed by Brian Murray
Status: Needs review
Proposed branch: ubuntu-dev-tools:import-bug-fix
Merge into: ubuntu-dev-tools:master
Diff against target: 31 lines (+9/-0)
2 files modified
debian/changelog (+5/-0)
import-bug-from-debian (+4/-0)
Reviewer Review Type Date Requested Status
Mattia Rizzolo Needs Fixing
Review via email: mp+406679@code.launchpad.net

Description of the change

The tool import-bug-from-debian can create bug descriptions which look
like the following:

[<email.message.Message object at 0x7fbe14096fa0>,
<email.message.Message object at 0x7fbe15143820>]

I believe this is because the first message has multiple payloads and
import-bug-from-debian does not handle this. As an example of what goes
wrong please see:

http://launchpad.net/bugs/1894141

I've been using this successfully for almost a year now.

To post a comment you must log in.
Revision history for this message
Mattia Rizzolo (mapreri) wrote :

Right, I think your analysis is correct.

However I think a more formally appropriate fix would be to iterate through the payloads (in case of a multipart message), gather all the inline pieces of text/plain, concatenate them and use the resulting string. Mails with multiple inline text/plain parts are incredibly rare, but I've seen submitters of Debian bugs doing that to interleave descriptions to attachments.

See an example here: https://bugs.debian.org/981577

Anyway, rather than that `if isinstance()` check, you should be using .is_multipart(), followed by checking with .get_content_type() to verify it's really text/plain.
Everything while looping through .walk().

At the very very least, I'd rather the code gave up if it detected a too complex mail, erroring out saying so.

review: Needs Fixing
Revision history for this message
Dan Streetman (ddstreet) wrote :

Unmerged commits

a24f1bc... by Brian Murray

import-bug-from-debian:

* import-bug-from-debian:
  + Don't create a bug description with email.message.Message objects.
    Closes #969510

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 0837626..684015e 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -5,6 +5,11 @@ ubuntu-dev-tools (0.185) UNRELEASED; urgency=medium
6 + Fix crash due to PersonalPackageArchiveSourcePackage() returning the
7 wrong object when requesting a download url. LP: #1938659
8
9+ [ Brian Murray ]
10+ * import-bug-from-debian:
11+ + Don't create a bug description with email.message.Message objects.
12+ Closes #969510
13+
14 -- Mattia Rizzolo <mattia@debian.org> Wed, 04 Aug 2021 11:59:05 +0200
15
16 ubuntu-dev-tools (0.184) experimental; urgency=medium
17diff --git a/import-bug-from-debian b/import-bug-from-debian
18index 9aeac46..fccf395 100755
19--- a/import-bug-from-debian
20+++ b/import-bug-from-debian
21@@ -102,6 +102,10 @@ def main():
22 subject = bug.subject
23 log = debianbts.get_bug_log(bug_num)
24 summary = log[0]['message'].get_payload()
25+ if isinstance(log[0]['message'].get_payload(), str):
26+ summary = log[0]['message'].get_payload()
27+ else:
28+ summary = log[0]['message'].get_payload()[0].get_payload()
29 target = ubuntu.getSourcePackage(name=ubupackage)
30 if target is None:
31 Logger.error("Source package '%s' is not in Ubuntu. Please specify "

Subscribers

People subscribed via source and target branches