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
diff --git a/debian/changelog b/debian/changelog
index 0837626..684015e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,11 @@ ubuntu-dev-tools (0.185) UNRELEASED; urgency=medium
5 + Fix crash due to PersonalPackageArchiveSourcePackage() returning the5 + Fix crash due to PersonalPackageArchiveSourcePackage() returning the
6 wrong object when requesting a download url. LP: #19386596 wrong object when requesting a download url. LP: #1938659
77
8 [ Brian Murray ]
9 * import-bug-from-debian:
10 + Don't create a bug description with email.message.Message objects.
11 Closes #969510
12
8 -- Mattia Rizzolo <mattia@debian.org> Wed, 04 Aug 2021 11:59:05 +020013 -- Mattia Rizzolo <mattia@debian.org> Wed, 04 Aug 2021 11:59:05 +0200
914
10ubuntu-dev-tools (0.184) experimental; urgency=medium15ubuntu-dev-tools (0.184) experimental; urgency=medium
diff --git a/import-bug-from-debian b/import-bug-from-debian
index 9aeac46..fccf395 100755
--- a/import-bug-from-debian
+++ b/import-bug-from-debian
@@ -102,6 +102,10 @@ def main():
102 subject = bug.subject102 subject = bug.subject
103 log = debianbts.get_bug_log(bug_num)103 log = debianbts.get_bug_log(bug_num)
104 summary = log[0]['message'].get_payload()104 summary = log[0]['message'].get_payload()
105 if isinstance(log[0]['message'].get_payload(), str):
106 summary = log[0]['message'].get_payload()
107 else:
108 summary = log[0]['message'].get_payload()[0].get_payload()
105 target = ubuntu.getSourcePackage(name=ubupackage)109 target = ubuntu.getSourcePackage(name=ubupackage)
106 if target is None:110 if target is None:
107 Logger.error("Source package '%s' is not in Ubuntu. Please specify "111 Logger.error("Source package '%s' is not in Ubuntu. Please specify "

Subscribers

People subscribed via source and target branches