internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: fedora-infra/bodhi

Issue:
Move bug commenting into async process
This should help a lot with performance, but let's leverage fedmsg and move bug commenting (the initial bug comment) out of `Update.new(..)` and into a new fedmsg consumer that gets run on bodhi-backend01.  It can listen for when new updates are created by the frontend and then do some of the more expensive tasks (like commenting on bugs..).



Discussion:
Great idea! 

I think a ton of the slowness is coming from querying the wiki in `Package.fetch_test_cases`, so we should do that in this consumer as well.

And I think it's really helpful to reduce the time consumption of waiting.


Resolving patch:
diff --git a/bodhi/consumers/updates.py b/bodhi/consumers/updates.py
--- a/bodhi/consumers/updates.py
+++ b/bodhi/consumers/updates.py
@@ -121,9 +121,15 @@ def consume(self, message):
                 raise NotImplementedError("Should never get here.")
 
             self.work_on_bugs(session, update, bugs)
+            self.fetch_test_cases(session, update)
 
         log.info("Updates Handler done with %s, %s" % (alias, topic))
 
+    def fetch_test_cases(self, session, update):
+        """ Query the wiki for test cases for each package """
+        for build in update.builds:
+            build.package.fetch_test_cases(session)
+
     def work_on_bugs(self, session, update, bugs):
 
         if not self.handle_bugs:
diff --git a/bodhi/services/updates.py b/bodhi/services/updates.py
--- a/bodhi/services/updates.py
+++ b/bodhi/services/updates.py
@@ -323,9 +323,6 @@ def new_update(request):
                 request.db.add(package)
                 request.db.flush()
 
-            # Fetch test cases from the wiki
-            package.fetch_test_cases(request.db)
-
             build = Build.get(nvr, request.db)
 
             if build is None:


Test patch:
Repository: fedora-infra/bodhi

Issue:
Bodhi client crashes when expecting a comment of 10 chars without a useful message
Often when the fix is "fix FTBFS" or "Rebuild" due to the failure a message of 10 chars it should at least report why it's crashing. 

$ fedpkg update
/usr/lib/python2.7/site-packages/fedpkg/cli.py:169: DeprecationWarning: Commands._hash_file is deprecated and will be removed eventually.
    Please use Commands.lookasidecache.hash_file instead.
  hash = self.cmd._hash_file('bodhi.template', 'sha1')
Creating a new update for  nmap-6.47-5.fc23 
Password for pbrobinson: 
Creating a new update for  nmap-6.47-5.fc23 
Traceback (most recent call last):
  File "/usr/bin/bodhi", line 537, in <module>
    main()
  File "/usr/bin/bodhi", line 225, in main
    data = bodhi.save(**update_args)
  File "/usr/lib/python2.7/site-packages/fedora/client/bodhi.py", line 107, in wrapper
    raise BodhiClientException(problems)
fedora.client.bodhi.BodhiClientException: Shorter than minimum length 10
Could not generate update request: Command 'bodhi --new --release f23 --file bodhi.template nmap-6.47-5.fc23 --username pbrobinson' returned non-zero exit status 1



Discussion:
Seems like there's two separate issues going on here:
- The server could be updated to have a shorter minimum character requirement.  '2' seems okay so people can just say '+1' or ':)'.
- The client could catch those `BodhiException`s and print them out more nicely.


Resolving patch:
diff --git a/bodhi/schemas.py b/bodhi/schemas.py
--- a/bodhi/schemas.py
+++ b/bodhi/schemas.py
@@ -116,7 +116,10 @@ class TestcaseFeedbacks(colander.SequenceSchema):
 
 class SaveCommentSchema(CSRFProtectedSchema, colander.MappingSchema):
     update = colander.SchemaNode(colander.String())
-    text = colander.SchemaNode(colander.String())
+    text = colander.SchemaNode(
+        colander.String(),
+        missing='',
+    )
     karma = colander.SchemaNode(
         colander.Integer(),
         validator=colander.Range(min=-1, max=1),
@@ -170,7 +173,7 @@ class SaveUpdateSchema(CSRFProtectedSchema, colander.MappingSchema):
     )
     notes = colander.SchemaNode(
         colander.String(),
-        validator=colander.Length(min=10),
+        validator=colander.Length(min=2),
     )
     autokarma = colander.SchemaNode(
         colander.Boolean(),
@@ -647,7 +650,7 @@ class SaveOverrideSchema(CSRFProtectedSchema, colander.MappingSchema):
 
     notes = colander.SchemaNode(
         colander.String(),
-        validator=colander.Length(min=10),
+        validator=colander.Length(min=2),
     )
 
     expiration_date = colander.SchemaNode(


Test patch:
Repository: fedora-infra/bodhi

Issue:
setup.py test doesn't include extra_requires from fedmsg deps
```
======================================================================
ERROR: Failure: ImportError (No module named psutil)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/decause/.virtualenvs/bodhi-python2.7/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/decause/.virtualenvs/bodhi-python2.7/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/decause/.virtualenvs/bodhi-python2.7/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/decause/code/bodhi/bodhi/tests/test_masher.py", line 27, in <module>
    from bodhi.consumers.masher import Masher, MasherThread
  File "/home/decause/code/bodhi/bodhi/consumers/masher.py", line 30, in <module>
    import fedmsg.consumers
  File "/home/decause/code/bodhi/.eggs/fedmsg-0.16.0-py2.7.egg/fedmsg/consumers/__init__.py", line 25, in <module>
    import psutil
ImportError: No module named psutil

----------------------------------------------------------------------
Ran 335 tests in 138.787s

FAILED (errors=1)
```



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -57,7 +57,9 @@
     # External resources
     'python-bugzilla',
     'simplemediawiki',
-    'fedmsg',
+
+    # "python setup.py test" needs one of fedmsg's setup.py extra_requires
+    'fedmsg[consumers]',
 
     'Sphinx',
 


Test patch:
Repository: fedora-infra/bodhi

Issue:
500 Server Error
https://bodhi.fedoraproject.org/updates/FEDORA-2015-12838 gives

500 Server Error

```
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pyramid_mako/__init__.py", line 148, in __call__ result = template.render_unicode(**system)
File "/usr/lib/python2.7/site-packages/mako/template.py", line 452, in render_unicode as_unicode=True)
File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 783, in _render **_kwargs_for_callable(callable_, data))
File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 815, in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/usr/lib/python2.7/site-packages/mako/runtime.py", line 841, in _exec_template callable_(context, *args, **kwargs) File "master_html", line 200, in render_body
File "/usr/lib/python2.7/site-packages/bodhi/templates/update.html", line 506, in render_body % elif update.pushed and (update.status.description != 'stable' or (update.status.description == 'stable' and 'releng' in [group.name for group in request.user.groups])):
File "/usr/lib/python2.7/site-packages/munch/__init__.py", line 128, in __getattr__ raise AttributeError(k) AttributeError: groups
```



Discussion:
Confirmed.  Will fix ASAP.

Hotfixed in production for now.  Will submit a patch shortly.


Resolving patch:
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -1978,7 +1978,7 @@ def modified(self, update):
 
 class User(Base):
     __tablename__ = 'users'
-    __exclude_columns__ = ('comments', 'updates', 'groups', 'packages', 'stacks')
+    __exclude_columns__ = ('comments', 'updates', 'packages', 'stacks')
     __include_extras__ = ('avatar', 'openid')
     __get_by__ = ('name',)
 


Test patch:
Repository: fedora-infra/bodhi

Issue:
Bodhi changing a version number in Bugzilla
My [bug](https://bugzilla.redhat.com/show_bug.cgi?id=1252902) in bugzilla have bad version number when bodhi closed it.

Seems to me like bodhi have problems when the patch goes to multiple projects with _Resolves_ and _Related_ tags.



Discussion:
Confirmed.  It looks like bodhi used the version from the wrong build in a multi-build update to close the bug for that package.


Resolving patch:
diff --git a/bodhi/bugs.py b/bodhi/bugs.py
--- a/bodhi/bugs.py
+++ b/bodhi/bugs.py
@@ -93,12 +93,12 @@ def on_qa(self, bug_id, comment):
         except:
             log.exception("Unable to alter bug #%d" % bug_id)
 
-    def close(self, bug_id, fixedin=None):
+    def close(self, bug_id, versions):
         args = {}
-        if fixedin:
-            args['fixedin'] = fixedin
         try:
             bug = self.bz.getbug(bug_id)
+            if bug.component in versions:
+                args['fixedin'] = versions[bug.component]
             bug.close('NEXTRELEASE', **args)
         except xmlrpclib.Fault:
             log.exception("Unable to close bug #%d" % bug_id)
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -1957,8 +1957,12 @@ def testing(self, update):
             bugtracker.on_qa(self.bug_id, comment)
 
     def close_bug(self, update):
-        ver = '-'.join(get_nvr(update.builds[0].nvr)[-2:])
-        bugtracker.close(self.bug_id, fixedin=ver)
+        # Build a mapping of package names to build versions
+        # so that .close() can figure out which build version fixes which bug.
+        versions = dict([
+            (get_nvr(b.nvr)[0], b.nvr) for b in update.builds
+        ])
+        bugtracker.close(self.bug_id, versions=versions)
 
     def modified(self, update):
         """ Change the status of this bug to MODIFIED """


Test patch:
diff --git a/bodhi/tests/test_masher.py b/bodhi/tests/test_masher.py
--- a/bodhi/tests/test_masher.py
+++ b/bodhi/tests/test_masher.py
@@ -731,7 +731,8 @@ def test_modify_stable_bugs(self, close, comment, *args):
             t.db = session
             t.work()
             t.db = None
-        close.assert_called_with(12345, fixedin=u'2.0-1.fc17')
+        close.assert_called_with(12345, versions=dict(
+            bodhi=u'bodhi-2.0-1.fc17'))
         comment.assert_called_with(12345, u'bodhi-2.0-1.fc17 has been pushed to the Fedora 17 stable repository. If problems still persist, please make note of it in this bug report.')
 
     @mock.patch(**mock_taskotron_results)
Repository: fedora-infra/bodhi

Issue:
Reset karma on updates when an edit changes the list of builds.
https://bodhi.fedoraproject.org/updates/NetworkManager-pptp-1.1.0-3.20150428git695d4f2.el7/edit

This one had -1 karma threshold and got a -1 karma. It was fixed since, but as karma count was not reset it keeps unpushing itself.



Discussion:
Just to be clear:
- What did you do to fix the update?  Did you edit it to change the build?


Resolving patch:
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -819,6 +819,12 @@ def edit(cls, request, data):
                     # We still warn in case the config gets messed up.
                     log.warn('%s has no pending_testing_tag' % up.release.name)
 
+        # And, updates with new or removed builds always get their karma reset.
+        # https://github.com/fedora-infra/bodhi/issues/511
+        if new_builds or removed_builds:
+            data['karma'] = 0
+            data['karma_critpath'] = 0
+
         new_bugs = up.update_bugs(data['bugs'], db)
         del(data['bugs'])
 


Test patch:
diff --git a/bodhi/tests/functional/test_updates.py b/bodhi/tests/functional/test_updates.py
--- a/bodhi/tests/functional/test_updates.py
+++ b/bodhi/tests/functional/test_updates.py
@@ -1926,3 +1926,27 @@ def test_update_meeting_requirements_present(self):
         actual = res.json_body['update']['meets_testing_requirements']
         expected = False
         self.assertEquals(actual, expected)
+
+    @mock.patch(**mock_valid_requirements)
+    @mock.patch('bodhi.notifications.publish')
+    def test_edit_testing_update_reset_karma(self, publish, *args):
+        nvr = u'bodhi-2.0.0-2.fc17'
+        args = self.get_update(nvr)
+        r = self.app.post_json('/updates/', args)
+        publish.assert_called_with(topic='update.request.testing', msg=ANY)
+
+        # Mark it as testing and give it 2 karma
+        upd = Update.get(nvr, self.db)
+        upd.status = UpdateStatus.testing
+        upd.request = None
+        upd.karma = 2
+        self.db.flush()
+
+        # Then.. edit it and change the builds!
+        args['edited'] = args['builds']
+        args['builds'] = 'bodhi-2.0.0-3.fc17'
+        r = self.app.post_json('/updates/', args)
+        up = r.json_body
+        self.assertEquals(up['title'], u'bodhi-2.0.0-3.fc17')
+        # This is what we really want to test here.
+        self.assertEquals(up['karma'], 0)
Repository: fedora-infra/bodhi

Issue:
Incorrect order of Feedback columns for positive/negative karma
Hi,

my bad I did not check which radio button adds positive/negative karma properly. However, if you look at any update with some karmas, there are two places:
1) Related Bugs
2) Feedback

1) shows karmas for bugs in positive | negative order of columns. 2) shows negative | neutral | positive order. Which is a little user-unfriendly. Would it be possible to switch ordering of 2) to positive | neutral | negative so it complies with ordering of 1)? If not, the issue can be closed.

[1] https://bodhi.fedoraproject.org/updates/golang-1.5-8.fc23

Jan



Discussion:
Thanks for the great ticket Jan!

I'll do the opposite, if you don't mind, and switch the order of 1) since I worry that some people are already used to the buttons for 2).


Resolving patch:
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -957,7 +957,7 @@ def get_bug_karma(self, bug):
                         good += 1
                     elif feedback.karma < 0:
                         bad += 1
-        return good, bad * -1
+        return bad * -1, good
 
     def get_testcase_karma(self, testcase):
         good, bad, seen = 0, 0, set()
@@ -971,7 +971,7 @@ def get_testcase_karma(self, testcase):
                         good += 1
                     elif feedback.karma < 0:
                         bad += 1
-        return good, bad * -1
+        return bad * -1, good
 
     def assign_alias(self):
         """Return the next available update ID.


Test patch:
Repository: fedora-infra/bodhi

Issue:
Don't fiddle with "fixed in" all the time
The "fixed in field" should be probably additive, that way all the releases where the errata was issued should stay listed. E.g. [1] should list rubygem-rack-1.6.1-2.fc22 as well as rubygem-rack-1.5.2-5.fc21 and don't change the field all the time.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1248923



Discussion:

Resolving patch:
diff --git a/bodhi/bugs.py b/bodhi/bugs.py
--- a/bodhi/bugs.py
+++ b/bodhi/bugs.py
@@ -97,8 +97,18 @@ def close(self, bug_id, versions):
         args = {}
         try:
             bug = self.bz.getbug(bug_id)
+            # If this bug is for one of these builds...
             if bug.component in versions:
-                args['fixedin'] = versions[bug.component]
+                version = versions[bug.component]
+                # Get the existing list
+                fixedin = [v.strip() for v in bug.fixed_in.split(',')]
+                # Strip out any empty strings
+                fixedin = [v for v in fixedin if v.strip()]
+                # And add our build if its not already there
+                if version not in fixedin:
+                    fixedin.append(version)
+                args['fixedin'] = ", ".join(fixedin)
+
             bug.close('NEXTRELEASE', **args)
         except xmlrpclib.Fault:
             log.exception("Unable to close bug #%d" % bug_id)
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -1960,9 +1960,12 @@ def testing(self, update):
     def close_bug(self, update):
         # Build a mapping of package names to build versions
         # so that .close() can figure out which build version fixes which bug.
-        versions = dict([
-            (get_nvr(b.nvr)[0], b.nvr) for b in update.builds
-        ])
+        versions = dict([(
+            get_nvr(b.nvr)[0],
+            # Strip off the .fc23 at the end of the nvr to try and match the
+            # way the anaconda team uses the fixedin field.
+            b.nvr.rsplit('.', 1)[0]
+        ) for b in update.builds])
         bugtracker.close(self.bug_id, versions=versions)
 
     def modified(self, update):


Test patch:
diff --git a/bodhi/tests/test_masher.py b/bodhi/tests/test_masher.py
--- a/bodhi/tests/test_masher.py
+++ b/bodhi/tests/test_masher.py
@@ -731,8 +731,7 @@ def test_modify_stable_bugs(self, close, comment, *args):
             t.db = session
             t.work()
             t.db = None
-        close.assert_called_with(12345, versions=dict(
-            bodhi=u'bodhi-2.0-1.fc17'))
+        close.assert_called_with(12345, versions=dict(bodhi=u'bodhi-2.0-1'))
         comment.assert_called_with(12345, u'bodhi-2.0-1.fc17 has been pushed to the Fedora 17 stable repository. If problems still persist, please make note of it in this bug report.')
 
     @mock.patch(**mock_taskotron_results)
Repository: fedora-infra/bodhi

Issue:
epel5 needs more createrepo_c compatibility for security plugin
From: https://bugzilla.redhat.com/show_bug.cgi?id=1256336

The rhel5 yum security plugin is unable to deal with the updateinfo being .bz2. It wants it to be .gz apparently. 

Not sure if this is something we need to change in createrepo_c, or in bodhi2 when it injects the security info in.



Discussion:

Resolving patch:
diff --git a/bodhi/metadata.py b/bodhi/metadata.py
--- a/bodhi/metadata.py
+++ b/bodhi/metadata.py
@@ -66,10 +66,11 @@ def __init__(self, release, request, db, path):
             # yum on py2.4 doesn't support sha256 (#1080373)
             if 'el5' in self.repo or '5E' in self.repo:
                 self.hash_type = cr.SHA1
-
-            # FIXME: I'm not sure which versions of RHEL support xz metadata
-            # compression, so use the lowest common denominator for now.
-            self.comp_type = cr.BZ2
+                self.comp_type = cr.GZ
+            else:
+                # FIXME: I'm not sure which versions of RHEL support xz metadata
+                # compression, so use the lowest common denominator for now.
+                self.comp_type = cr.BZ2
 
         # Load from the cache if it exists
         self.cached_repodata = os.path.join(self.repo, '..', self.tag +


Test patch:
Repository: fedora-infra/bodhi

Issue:
Wrong resolution for BZ tickets
It used to be "CLOSED ERRATA" [1], not it says "CLOSED NEXTRELEASE" [2]. Or am I mistaken and the resolution for upcoming release is different from stable releases?

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1233336#c5
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1205294#c6



Discussion:
Ah, I am not mistaken: https://bugzilla.redhat.com/show_bug.cgi?id=1248923

For reference:  https://fedoraproject.org/wiki/BugZappers/BugStatusWorkFlow


Resolving patch:
diff --git a/bodhi/bugs.py b/bodhi/bugs.py
--- a/bodhi/bugs.py
+++ b/bodhi/bugs.py
@@ -114,7 +114,7 @@ def close(self, bug_id, versions):
                 # - space-separated if there's more than one.
                 args['fixedin'] = " ".join(fixedin)
 
-            bug.close('NEXTRELEASE', **args)
+            bug.close('ERRATA', **args)
         except xmlrpclib.Fault:
             log.exception("Unable to close bug #%d" % bug_id)
 


Test patch:
Repository: fedora-infra/bodhi

Issue:
/updates/? returns too much data
I want to continuously consume information about the latest stable updates for all Fedora releases in an automated way.

It's my impression that some updates have status "testing", potentially for a long time, before they transition to status "stable".

When I

```
GET https://bodhi.fedoraproject.org/updates/?release=f21
Accept: application/json
```

the result is one page of information about updates. When I max out the page size (rows_per_page=100), the result is 96 pages of updates. Since these are sorted by date_submitted (not updated when an update moves from "testing" to "stable"), as I continuously check for new updates, I would need to check every single page to see if any update has changed state.

If I instead consume 

```
https://bodhi.fedoraproject.org/updates/?release=f21&status=stable
```

since items are sorted by date_submitted, I would again have to check every page to see if new updates are available and which ones they are (now only 84 pages).

Other users might want to do something similar, filtering on different attributes.

Since I want to consume this information continuously (say check for new updates every couple hours) and not put undue load on your web servers / databases, I would like to make the following request:

I suggest creating a new route /updates/ids that lists only the updateid of updates matching request conditions. For this endpoint, the rows_per_page could safely be much greater, say 1000 or 10000.

```
https://bodhi.fedoraproject.org/updates/ids?release=f21&status=stable
```

This would return something like:

``` javascript
{
    "rows_per_page": 1000,
    "total": 9568,
    "pages": 10,
    "updates": [
        "FEDORA-2015-13080",
        "FEDORA-2015-13129",
        ...
    ]
}
```

This is a fairly simple addition, and would make it much easier for users to consume information about updates on an ongoing basis.

Let me know if you think this is a good idea. I'm happy to submit a pull request.



Discussion:
This is not a bad idea, but have you considered using [fedmsg](http://fedmsg.com) to receive events about updates being pushed to stable?

It even has its own history of events where you could see just [the events where updates are pushed to stable](https://apps.fedoraproject.org/datagrepper/raw?topic=org.fedoraproject.prod.bodhi.update.complete.stable).


Resolving patch:
diff --git a/bodhi/schemas.py b/bodhi/schemas.py
--- a/bodhi/schemas.py
+++ b/bodhi/schemas.py
@@ -236,7 +236,7 @@ class PaginatedSchema(colander.MappingSchema):
 
     rows_per_page = colander.SchemaNode(
         colander.Integer(),
-        validator=colander.Range(min=1, max=100),
+        validator=colander.Range(min=1, max=1000),
         location="querystring",
         missing=20,
     )


Test patch: