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

Issue:
requests not shown on updates page
The https://bodhi.fedoraproject.org/updates/?user=xxx page show all updates and their status, but not the requests (e.g. "submitted to stable") made for an update.



Discussion:

Resolving patch:
diff --git a/bodhi/services/updates.py b/bodhi/services/updates.py
--- a/bodhi/services/updates.py
+++ b/bodhi/services/updates.py
@@ -262,7 +262,8 @@ def query_updates(request):
         rows_per_page=rows_per_page,
         total=total,
         chrome=data.get('chrome'),
-        display_user=data.get('display_user'),
+        display_user=data.get('display_user', False),
+        display_request=data.get('display_request', True),
     )
 
 


Test patch:
Repository: fedora-infra/bodhi

Issue:
Return the test cases in the update json
The test cases are associated with each package, so we should iterate over each package for each build and throw the test cases into the json results as well.

This was originally filed accidentally in the wrong place as fedora-infra/fedmsg_meta_fedora_infrastructure#313.



Discussion:

Resolving patch:
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -1721,6 +1721,13 @@ def __json__(self, *args, **kwargs):
         # Also, put the update submitter's name in the same place we put
         # it for bodhi1 to make fedmsg.meta compat much more simple.
         result['submitter'] = result['user']['name']
+
+        # For https://github.com/fedora-infra/bodhi/issues/270, throw the JSON
+        # of the test cases in our output as well.
+        result['test_cases'] = [
+            test.__json__(*args, **kwargs) for test in self.full_test_cases
+        ]
+
         return result
 
 


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
@@ -481,6 +481,10 @@ def test_list_updates_by_approved_since(self):
         self.assertEquals(len(up['bugs']), 1)
         self.assertEquals(up['bugs'][0]['bug_id'], 12345)
 
+        # https://github.com/fedora-infra/bodhi/issues/270
+        self.assertEquals(len(up['test_cases']), 1)
+        self.assertEquals(up['test_cases'][0]['name'], u'Wat')
+
     def test_list_updates_by_invalid_approved_since(self):
         res = self.app.get('/updates/', {"approved_since": "forever"},
                            status=400)
Repository: fedora-infra/bodhi

Issue:
unpush seems to be broken
Clicking on the "unpush" button leads to the home page, with no visible effect.



Discussion:

Resolving patch:
diff --git a/bodhi/services/updates.py b/bodhi/services/updates.py
--- a/bodhi/services/updates.py
+++ b/bodhi/services/updates.py
@@ -121,6 +121,9 @@ def set_request(request):
         update.set_request(action, request.user.name)
     except BodhiException as e:
         request.errors.add('body', 'request', e.message)
+    except Exception as e:
+        log.exception("Unhandled exception in set_request")
+        request.errors.add('body', 'request', str(e))
 
     return dict(update=update)
 


Test patch:
Repository: fedora-infra/bodhi

Issue:
Change the BZ state to MODIFIED
Bodhi1 used to change the BZ ticket to MODIFIED, when the update was submitted. This does not look to be true anymore (goning to change the state myself).

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



Discussion:

Resolving patch:
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -636,8 +636,6 @@ def new(cls, request, data):
                     if bug.security:
                         data['type'] = UpdateType.security
                 bugs.append(bug)
-                bugtracker.comment(bug_num, config['initial_bug_msg'] % (
-                           data['title'], data['release'].long_name, bug.url))
         data['bugs'] = bugs
 
         # If no requirements are provided, then gather some defaults from the
@@ -672,6 +670,16 @@ def new(cls, request, data):
         db.add(up)
         db.flush()
 
+        # Now that the update has been created, we have an alias and a url,
+        # so we can comment on some bugs.
+        # TODO - https://github.com/fedora-infra/bodhi/issues/314
+        for bug in bugs:
+            bug.add_comment(up, config['initial_bug_msg'] % (
+                data['title'], data['release'].long_name, up.url()))
+            # And mark it as modified
+            # https://github.com/fedora-infra/bodhi/issues/225
+            bug.modified()
+
         return up, caveats
 
     @classmethod
@@ -756,7 +764,10 @@ def edit(cls, request, data):
         del(data['bugs'])
         for bug in new_bugs:
             bug.add_comment(up, config['initial_bug_msg'] % (
-                data['title'], data['release'].long_name, up.url))
+                data['title'], data['release'].long_name, up.url()))
+            # And mark it as modified
+            # https://github.com/fedora-infra/bodhi/issues/225
+            bug.modified()
 
         req = data.pop("request", None)
         if req is not None:


Test patch:
Repository: fedora-infra/bodhi

Issue:
Handle InvalidToken from the captcha
Traceback from production:

```
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/paste/deploy/config.py", line 291, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/pyramid/router.py", line 242, in __call__
    response = self.invoke_subrequest(request, use_tweens=True)
  File "/usr/lib/python2.7/site-packages/pyramid/router.py", line 217, in invoke_subrequest
    response = handle_request(request)
  File "/usr/lib/python2.7/site-packages/pyramid/tweens.py", line 46, in excview_tween
    response = view_callable(exc, request)
  File "/usr/lib/python2.7/site-packages/pyramid/config/views.py", line 385, in viewresult_to_response
    result = view(context, request)
  File "/usr/lib/python2.7/site-packages/pyramid/tweens.py", line 21, in excview_tween
    response = handler(request)
  File "/usr/lib/python2.7/site-packages/pyramid_tm/__init__.py", line 82, in tm_tween
    reraise(*exc_info)
  File "/usr/lib/python2.7/site-packages/pyramid_tm/__init__.py", line 63, in tm_tween
    response = handler(request)
  File "/usr/lib/python2.7/site-packages/pyramid/router.py", line 163, in handle_request
    response = view_callable(context, request)
  File "/usr/lib/python2.7/site-packages/pyramid/config/views.py", line 355, in rendered_view
    result = view(context, request)
  File "/usr/lib/python2.7/site-packages/pyramid/config/views.py", line 501, in _requestonly_view
    response = view(request)
  File "/usr/lib/python2.7/site-packages/bodhi/captcha.py", line 119, in captcha_image
    plainkey = decrypt(cipherkey, request.registry.settings)
  File "/usr/lib/python2.7/site-packages/bodhi/captcha.py", line 112, in decrypt
    plaintext = engine.decrypt(ciphertext, ttl=int(settings['captcha.ttl']))
  File "/usr/lib64/python2.7/site-packages/cryptography/fernet.py", line 93, in decrypt
    raise InvalidToken
InvalidToken
```



Discussion:

Resolving patch:
diff --git a/bodhi/captcha.py b/bodhi/captcha.py
--- a/bodhi/captcha.py
+++ b/bodhi/captcha.py
@@ -22,6 +22,7 @@
 
 from PIL import Image, ImageDraw, ImageFont
 
+from pyramid.httpexceptions import HTTPGone, HTTPNotFound
 from pyramid.view import view_config
 
 
@@ -104,12 +105,23 @@ def encrypt(plaintext, settings):
 
 
 def decrypt(ciphertext, settings):
+    ttl = int(settings['captcha.ttl'])
     secret = settings['captcha.secret']
     engine = cryptography.fernet.Fernet(secret)
+
     if isinstance(ciphertext, six.text_type):
         ciphertext = ciphertext.encode('utf-8')
-    ciphertext = base64.urlsafe_b64decode(ciphertext)
-    plaintext = engine.decrypt(ciphertext, ttl=int(settings['captcha.ttl']))
+
+    try:
+        ciphertext = base64.urlsafe_b64decode(ciphertext)
+    except TypeError:
+        raise HTTPNotFound("%s is garbage" % ciphertext)
+
+    try:
+        plaintext = engine.decrypt(ciphertext, ttl=ttl)
+    except cryptography.fernet.InvalidToken:
+        raise HTTPGone('captcha token is no longer valid')
+
     return plaintext.decode('utf-8')
 
 


Test patch:
Repository: fedora-infra/bodhi

Issue:
updates-testing report links are 404
https://lists.fedoraproject.org/pipermail/test/2015-August/127409.html has links like: 

The following Fedora 23 Security updates need testing:
 Age  URL
  15  https://bodhi.fedoraproject.org/F23/FEDORA-2015-12739
...
but those urls give a 404 error.



Discussion:
Also, they aren't very informative without the update name... so it would be great to add that back in there. 


Resolving patch:
diff --git a/bodhi/masher.py b/bodhi/masher.py
--- a/bodhi/masher.py
+++ b/bodhi/masher.py
@@ -768,20 +768,20 @@ def send_testing_digest(self):
             if security_updates:
                 maildata += sechead % prefix
                 for update in security_updates:
-                    maildata += u' %3i  %s%s\n' % (
+                    maildata += u' %3i  %s   %s\n' % (
                         update.days_in_testing,
-                        config.get('base_address'),
-                        update.get_url())
+                        update.abs_url(),
+                        update.title)
                 maildata += '\n\n'
 
             critpath_updates = self.get_unapproved_critpath_updates(prefix)
             if critpath_updates:
                 maildata += crithead % prefix
                 for update in self.get_unapproved_critpath_updates(prefix):
-                    maildata += u' %3i  %s%s\n' % (
+                    maildata += u' %3i  %s   %s\n' % (
                         update.days_in_testing,
-                        config.get('base_address'),
-                        update.get_url())
+                        update.abs_url(),
+                        update.title)
                 maildata += '\n\n'
 
             maildata += testhead % prefix


Test patch:
Repository: fedora-infra/bodhi

Issue:
Use `since` param when querying ResultsDB
You query ResultsDB for all the results available for the particular update. That is not "wrong" per-se, but when an update is changed, after the tests are finished, you might be showing (e.g.) PASSED result for Depcheck, although it is more like "not tested yet".

ResultsDB's query engine supports `since` param, that takes a timestamp in ISO8601(YYYY-MM-DDTHH:MM:SS) format, and when used ResultsDB only returns results that are newer than the datetime specified.

I'm not sure if the update has something like "last modified" value, but if the last-modified is anything else than "created at", I'd suggest using the `since` param, to ensure the right information is shown.



Discussion:
:+1: good idea.


Resolving patch:
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -1538,7 +1538,14 @@ def check_requirements(self, session, settings):
         requirements = list(requirements)
 
         try:
-            results = bodhi.util.taskotron_results(settings, title=self.title)
+            # https://github.com/fedora-infra/bodhi/issues/362
+            since = self.last_modified.isoformat().rsplit('.', 1)[0]
+        except Exception as e:
+            return False, "Failed to determine last_modified: %r" % e.message
+
+        try:
+            query = dict(title=self.title, since=since)
+            results = bodhi.util.taskotron_results(settings, **query)
         except IOError as e:
             return False, "Failed to talk to taskotron: %r" % e.message
 
@@ -1592,6 +1599,25 @@ def check_karma_thresholds(self, agent):
     def requirements_json(self):
         return json.dumps(list(tokenize(self.requirements or '')))
 
+    @property
+    def last_modified(self):
+        """ Return the last time this update was edited or created.
+
+        This gets used specifically by taskotron/resultsdb queries so we only
+        query for depcheck runs that occur *after* the last time this update
+        (in its current form) was in play.
+        """
+
+        # Prune out None values that have not been set
+        possibilities = [self.date_submitted, self.date_modified]
+        possibilities = [p for p in possibilities if p]
+
+        if not possibilities:  # Should be un-possible.
+            raise ValueError("Update has no timestamps set: %r" % self)
+
+        possibilities.sort()  # Sort smallest to largest (oldest to newest)
+        return possibilities[-1]  # Return the last one
+
     @property
     def critpath_approved(self):
         """ Return whether or not this critpath update has been approved """


Test patch:
Repository: fedora-infra/bodhi

Issue:
Don't add people to an empty group
```
isv successfully logged in
groups = [u'']
Adding isv to  group
```



Discussion:

Resolving patch:
diff --git a/bodhi/security.py b/bodhi/security.py
--- a/bodhi/security.py
+++ b/bodhi/security.py
@@ -101,6 +101,10 @@ def remember_me(context, request, info, *args, **kw):
 
     # Keep track of what groups the user is a memeber of
     for group_name in info['groups']:
+        # Drop empty group names https://github.com/fedora-infra/bodhi/issues/306
+        if not group_name.strip():
+            continue
+
         group = db.query(Group).filter_by(name=group_name).first()
         if not group:
             group = Group(name=group_name)


Test patch:
Repository: fedora-infra/bodhi

Issue:
Markdown unordered lists do not work in update notes
Filling the update notes under https://bodhi.fedoraproject.org/updates/new with unordered lists in markdown syntax (https://help.github.com/articles/markdown-basics/) does not work, neither in the preview nor after submitting, visit e.g. https://bodhi.fedoraproject.org/updates/phpMyAdmin-4.4.14-1.fc23 with Firefox 38 ESR from RHEL/CentOS 6. It seems to work properly with a text browser such as w3m (CSS issue?).



Discussion:
They do work, it just requires that you put an extra newline in front of the list like this:
- this
- is
- a
- list

No, they do not work. And this seems to be a CSS issue.

I just tested with a comment on that update.  To be clear, you have to put an extra newline before the list, like this:

```
Some paragraph text goes here

* this
* is
* a
* list
```

![unordered-lists](https://cloud.githubusercontent.com/assets/10982488/9393886/1e2afa18-4785-11e5-9ee1-e1f5e37c7f6a.png)

Oh, you want the bullets to show up?

Yes, well, would be nice. This why I assumed a CSS issue (last sentence of my initial description) ;-)

Noting here that we'll need to surround each markdown area with a `<span class="markdown">...</span>` tag so that we can zero-in the CSS rules with something like:

``` css
.markdown {
   list-style-type: cjk-ideographic;
}
```


Resolving patch:
diff --git a/bodhi/ffmarkdown.py b/bodhi/ffmarkdown.py
--- a/bodhi/ffmarkdown.py
+++ b/bodhi/ffmarkdown.py
@@ -19,6 +19,7 @@
 """
 
 import markdown.inlinepatterns
+import markdown.postprocessors
 import markdown.util
 import pyramid.threadlocal
 
@@ -63,13 +64,26 @@ def handleMatch(self, m):
     MENTION_RE = r'(@\w+)'
     BUGZILLA_RE = r'(#[0-9]{5,})'
 
+    class SurroundProcessor(markdown.postprocessors.Postprocessor):
+        def run(self, text):
+            return "<div class='markdown'>" + text + "</div>"
+
     # Lastly, monkey-patch the build_inlinepatterns func to insert our patterns
-    original_builder = markdown.build_inlinepatterns
+    original_pattern_builder = markdown.build_inlinepatterns
 
-    def extended_builder(md_instance, **kwargs):
-        patterns = original_builder(md_instance, **kwargs)
+    def extended_pattern_builder(md_instance, **kwargs):
+        patterns = original_pattern_builder(md_instance, **kwargs)
         patterns['mention'] = MentionPattern(MENTION_RE, md_instance)
         patterns['bugzillas'] = BugzillaPattern(BUGZILLA_RE, md_instance)
         return patterns
 
-    markdown.build_inlinepatterns = extended_builder
+    markdown.build_inlinepatterns = extended_pattern_builder
+
+    original_postprocessor_builder = markdown.build_postprocessors
+
+    def extended_postprocessor_builder(md_instance, **kwargs):
+        processors = original_postprocessor_builder(md_instance, **kwargs)
+        processors['surround'] = SurroundProcessor(md_instance)
+        return processors
+
+    markdown.build_postprocessors = extended_postprocessor_builder


Test patch:
Repository: fedora-infra/bodhi

Issue:
Buildroot override search/list
In bodhi1, there was no way to search a package that is already added as buildroot override but I can browse through the list to check it.

Is there any plans for this in bodhi2? At least a way to find if someone has already added any version of a package in buildroot override?



Discussion:
I think it'll be pretty easy to have the primary search box return overrides as well.

+1 for searching


Resolving patch:
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -2060,6 +2060,11 @@ def expire(self):
             msg=dict(override=self),
         )
 
+    def __json__(self, *args, **kwargs):
+        result = super(BuildrootOverride, self).__json__(*args, **kwargs)
+        result['nvr'] = self.nvr  # For convenience
+        return result
+
 
 class Stack(Base):
     """
diff --git a/bodhi/services/overrides.py b/bodhi/services/overrides.py
--- a/bodhi/services/overrides.py
+++ b/bodhi/services/overrides.py
@@ -104,6 +104,13 @@ def query_overrides(request):
         query = query.join(BuildrootOverride.build).join(Build.release)
         query = query.filter(or_(*[Release.name==r.name for r in releases]))
 
+    like = data.get('like')
+    if like is not None:
+        query = query.join(BuildrootOverride.build)
+        query = query.filter(or_(*[
+            Build.nvr.like('%%%s%%' % like)
+        ]))
+
     submitter = data.get('user')
     if submitter is not None:
         query = query.filter(BuildrootOverride.submitter==submitter)


Test patch:
Repository: fedora-infra/bodhi

Issue:
add build completion to buildroot override add
From: https://fedorahosted.org/bodhi/ticket/788

"Small regression in Bodhi 2.0: builds completion fails to work in the override page.

I tried to submit an override for qpid-cpp-0.32-8.fc23 (due to boost rebuild induced ABI break), and it failed in both discovering the name of the source package and the nvr."



Discussion:
I guess I'm not sure if this is a client side (javascript) issue, where the build field should autocomplete with suggestions as you type stuff in.. or if it's a server-side (python) issue, where you could submit a portion of an nvr and the server would just figure out the right thing to do.  Can someone familiar with it fill me in more precisely on what bodhi1 did?

Since it's a part of Bodhi, I wasn't using that often, my memory could trick me. But if I remember well, it was supposed to provide suggestions as you type stuff in so it should be a javascript issue.

Thanks for the clarification.  This can probably be done without too much work.


Resolving patch:
diff --git a/bodhi/views/generic.py b/bodhi/views/generic.py
--- a/bodhi/views/generic.py
+++ b/bodhi/views/generic.py
@@ -16,6 +16,7 @@
 import sqlalchemy as sa
 
 from pyramid.security import authenticated_userid
+from pyramid.settings import asbool
 from pyramid.view import view_config, notfound_view_config
 from pyramid.exceptions import HTTPNotFound, HTTPForbidden
 
@@ -118,7 +119,7 @@ def latest_candidates(request):
     db = request.db
 
     @request.cache.cache_on_arguments()
-    def work(pkg):
+    def work(pkg, testing):
         result = []
         koji.multicall = True
 
@@ -128,8 +129,12 @@ def work(pkg):
                              (bodhi.models.ReleaseState.pending,
                               bodhi.models.ReleaseState.current)))
 
+        kwargs = dict(package=pkg, latest=True)
         for release in releases:
-            koji.listTagged(release.candidate_tag, package=pkg, latest=True)
+            koji.listTagged(release.candidate_tag, **kwargs)
+            if testing:
+                koji.listTagged(release.testing_tag, **kwargs)
+                koji.listTagged(release.pending_testing_tag, **kwargs)
 
         builds = koji.multiCall() or []  # Protect against None
 
@@ -145,12 +150,13 @@ def work(pkg):
 
 
     pkg = request.params.get('package')
-    log.debug('latest_candidate(%r)' % pkg)
+    testing = asbool(request.params.get('testing'))
+    log.debug('latest_candidate(%r, %r)' % (pkg, testing))
 
     if not pkg:
         return []
 
-    result = work(pkg)
+    result = work(pkg, testing)
 
     log.debug(result)
     return result


Test patch:
Repository: fedora-infra/bodhi

Issue:
overrides auto-search shows f21 candidates twice
![overrides](https://cloud.githubusercontent.com/assets/671366/9627790/2a11b728-5184-11e5-8834-b30c5c7341c8.png)
You can see that f21 candidate appearing twice. I also checked few other f21 packages and they are listed twice.

Please fix to show them once.



Discussion:
True enough!  The duplicates are coming from the server:

``` javascript
~❯ http get https://bodhi.fedoraproject.org/latest_candidates\?package\=nodejs-pinkie\&testing\=True
HTTP/1.1 200 OK
AppServer: proxy06.fedoraproject.org
AppTime: D=1957119
Connection: Keep-Alive
Content-Length: 106
Content-Type: application/json; charset=UTF-8
Date: Wed, 02 Sep 2015 12:37:24 GMT
Keep-Alive: timeout=15, max=500
Server: Apache/2.4.6 (Red Hat Enterprise Linux) mod_wsgi/3.4 Python/2.7.5
Strict-Transport-Security: max-age=15768000; includeSubDomains; preload

[
    {
        "id": 682197, 
        "nvr": "nodejs-pinkie-1.0.0-1.fc21"
    }, 
    {
        "id": 682197, 
        "nvr": "nodejs-pinkie-1.0.0-1.fc21"
    }
]
```

Note to developers, leaving off the `testing=True` flag yields only one result:

``` javascript
~❯ http get https://bodhi.fedoraproject.org/latest_candidates\?package\=nodejs-pinkie               
HTTP/1.1 200 OK
AppServer: proxy03.fedoraproject.org
AppTime: D=1782428
Connection: Keep-Alive
Content-Length: 53
Content-Type: application/json; charset=UTF-8
Date: Wed, 02 Sep 2015 12:38:28 GMT
Keep-Alive: timeout=15, max=500
Server: Apache/2.4.6 (Red Hat Enterprise Linux) mod_wsgi/3.4 Python/2.7.5
Strict-Transport-Security: max-age=15768000; includeSubDomains; preload

[
    {
        "id": 682197, 
        "nvr": "nodejs-pinkie-1.0.0-1.fc21"
    }
]
```


Resolving patch:
diff --git a/bodhi/views/generic.py b/bodhi/views/generic.py
--- a/bodhi/views/generic.py
+++ b/bodhi/views/generic.py
@@ -142,10 +142,14 @@ def work(pkg, testing):
             if isinstance(build, dict):
                 continue
             if build and build[0] and build[0][0]:
-                result.append({
+                item = {
                     'nvr': build[0][0]['nvr'],
                     'id': build[0][0]['id'],
-                })
+                }
+                # Prune duplicates
+                # https://github.com/fedora-infra/bodhi/issues/450
+                if item not in result:
+                    result.append(item)
         return result
 
 


Test patch: