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

Issue:
The waiverdb UI prompt doesn't explain what the text box is for
If a developer clicks on the waive button on an update, there is a pop up that has a text box and a submit button. The UI does not explain the purpose of this text box and it should. The text box is supposed to be justification for waiving the test failure.


Discussion:

Resolving patch:
diff --git a/bodhi/server/services/updates.py b/bodhi/server/services/updates.py
--- a/bodhi/server/services/updates.py
+++ b/bodhi/server/services/updates.py
@@ -569,7 +569,7 @@ def new_update(request):
                                 error_handler=bodhi.server.services.errors.json_handler)
 def waive_test_results(request):
     """
-    Waive test results on a given update when gating is on.
+    Waive all blocking test results on a given update when gating is on.
 
     Args:
         request (pyramid.request): The current request.


Test patch:
Repository: fedora-infra/bodhi

Issue:
search box doesn't sanitize trailing spaces
when one searches for a package and mistakenly hits an extra space after the package name, the search box doesn't sanitize. On the other hand, the URL if is passed with search=foo<some space> gets sanitized automatically.


Discussion:
I would like to work on this issue , any help given will be much appreciated
Hello @yashraj-Dhanuka,

The search box makes a few simultaneous API calls to search different objects (packages, users, buildroot overrides, and updates). The code that handles the update search is here, for example:

https://github.com/fedora-infra/bodhi/blob/3.0.0/bodhi/server/services/updates.py#L263-L266

Notice that there are validators (search that code for "validators") that run before that handler gets called. The fix would be to validate the search parameter there and trim its whitespace. It should be possible to write one validator that is used for all the APIs that the search box uses.

Resolving patch:
diff --git a/bodhi/server/schemas.py b/bodhi/server/schemas.py
--- a/bodhi/server/schemas.py
+++ b/bodhi/server/schemas.py
@@ -281,12 +281,14 @@ class SearchableSchema(colander.MappingSchema):
         colander.String(),
         location="querystring",
         missing=None,
+        preparer=[lambda x: x.strip() if x else x],
     )
 
     search = colander.SchemaNode(
         colander.String(),
         location="querystring",
         missing=None,
+        preparer=[lambda x: x.strip() if x else x],
     )
 
 


Test patch:
diff --git a/bodhi/tests/server/services/test_updates.py b/bodhi/tests/server/services/test_updates.py
--- a/bodhi/tests/server/services/test_updates.py
+++ b/bodhi/tests/server/services/test_updates.py
@@ -1517,6 +1517,27 @@ def test_updates_search(self):
         up = body['updates'][0]
         self.assertEquals(up['title'], u'bodhi-2.0-1.fc17')
 
+        # test that the search works for leading space
+        res = self.app.get('/updates/', {'search': ' bodh'})
+        body = res.json_body
+        self.assertEquals(len(body['updates']), 1)
+        up = body['updates'][0]
+        self.assertEquals(up['title'], u'bodhi-2.0-1.fc17')
+
+        # test that the search works for trailing space
+        res = self.app.get('/updates/', {'search': 'bodh '})
+        body = res.json_body
+        self.assertEquals(len(body['updates']), 1)
+        up = body['updates'][0]
+        self.assertEquals(up['title'], u'bodhi-2.0-1.fc17')
+
+        # test that the search works for both leading and trailing space
+        res = self.app.get('/updates/', {'search': ' bodh '})
+        body = res.json_body
+        self.assertEquals(len(body['updates']), 1)
+        up = body['updates'][0]
+        self.assertEquals(up['title'], u'bodhi-2.0-1.fc17')
+
     @unittest.skipIf(six.PY3, 'Not working with Python 3 yet')
     @mock.patch(**mock_valid_requirements)
     def test_list_updates_pagination(self, *args):
Repository: fedora-infra/bodhi

Issue:
Drop Bodhi's uniqueness constraint on e-mails
Bodhi currently has a uniqueness constraint on e-mails. This causes problems when users have more than one account and then change an account's e-mail address to be the same as the other accounts. When they log into Bodhi, they will get a crash because Bodhi hits the e-mail field's uniqueness constraint check. Bodhi does not look up users by e-mail address, and only uses the field to send e-mails, so it's ok if two accounts have the same address. We don't even need to index the field because we don't look up or search users by e-mail address.


Discussion:

Resolving patch:
diff --git a/bodhi/server/migrations/versions/39132c56a47e_drop_uniqueness_constraint_on_user_email.py b/bodhi/server/migrations/versions/39132c56a47e_drop_uniqueness_constraint_on_user_email.py
new file mode 100644
--- /dev/null
+++ b/bodhi/server/migrations/versions/39132c56a47e_drop_uniqueness_constraint_on_user_email.py
@@ -0,0 +1,40 @@
+# Copyright (c) 2018 Red Hat, Inc.
+#
+# This file is part of Bodhi.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+"""
+Drop uniqueness constraint on user email.
+
+Revision ID: 39132c56a47e
+Revises: 2c5d45f0c932
+Create Date: 2018-06-18 14:11:37.270185
+"""
+from alembic import op
+
+
+# revision identifiers, used by Alembic.
+revision = '39132c56a47e'
+down_revision = '2c5d45f0c932'
+
+
+def upgrade():
+    """Drop the uniqueness constraint on user.email."""
+    op.drop_constraint('users_email_key', 'users', type_='unique')
+
+
+def downgrade():
+    """Create a uniqueness constraint on user.email."""
+    op.create_unique_constraint('users_email_key', 'users', ['email'])
diff --git a/bodhi/server/models.py b/bodhi/server/models.py
--- a/bodhi/server/models.py
+++ b/bodhi/server/models.py
@@ -4204,7 +4204,7 @@ class User(Base):
     __get_by__ = ('name',)
 
     name = Column(Unicode(64), unique=True, nullable=False)
-    email = Column(UnicodeText, unique=True)
+    email = Column(UnicodeText)
 
     # A preference
     show_popups = Column(Boolean, default=True, server_default=text('TRUE'))


Test patch:
Repository: fedora-infra/bodhi

Issue:
bugs can't be marked as fixed
In https://bodhi.fedoraproject.org/updates/FEDORA-2018-1a6e6196b9 I tried to mark #1580530 as fixed by giving it +1 feedback (directly for that bug). But only generic karma was shown in my [comment](https://bodhi.fedoraproject.org/updates/ansible-2.5.5-2.fc28#comment-800652), not the specific bug report karma. Also in Bugs tab the feedback was not shown. I tried again (this time without giving generic karma), and [again](https://bodhi.fedoraproject.org/updates/ansible-2.5.5-2.fc28#comment-800653) it was ignored.

It seems that giving karma for particular bugs is broken atm.


Discussion:

Resolving patch:
diff --git a/bodhi/server/schemas.py b/bodhi/server/schemas.py
--- a/bodhi/server/schemas.py
+++ b/bodhi/server/schemas.py
@@ -145,6 +145,11 @@ class TestcaseFeedbacks(colander.SequenceSchema):
 class SaveCommentSchema(CSRFProtectedSchema, colander.MappingSchema):
     """An API schema for bodhi.server.services.comments.new_comment()."""
 
+    def deserialize(self, cstruct):
+        """Unflatten comment before parsing into Schema."""
+        appstruct = SaveCommentSchema().unflatten(cstruct)
+        return super(SaveCommentSchema, self).deserialize(appstruct)
+
     update = colander.SchemaNode(colander.String())
     text = colander.SchemaNode(
         colander.String(),


Test patch:
diff --git a/bodhi/tests/server/services/test_comments.py b/bodhi/tests/server/services/test_comments.py
--- a/bodhi/tests/server/services/test_comments.py
+++ b/bodhi/tests/server/services/test_comments.py
@@ -104,7 +104,8 @@ def test_commenting_with_critpath_feedback(self, publish):
     @mock.patch('bodhi.server.notifications.publish')
     def test_commenting_with_bug_feedback(self, publish):
         comment = self.make_comment()
-        comment['bug_feedback'] = [{'bug_id': 12345, 'karma': 1}]
+        comment['bug_feedback.0.bug_id'] = 12345
+        comment['bug_feedback.0.karma'] = 1
         res = self.app.post_json('/comments/', comment)
         self.assertNotIn('errors', res.json_body)
         self.assertIn('comment', res.json_body)
@@ -119,7 +120,8 @@ def test_commenting_with_bug_feedback(self, publish):
     @mock.patch('bodhi.server.notifications.publish')
     def test_commenting_with_testcase_feedback(self, publish):
         comment = self.make_comment()
-        comment['testcase_feedback'] = [{'testcase_name': "Wat", 'karma': -1}]
+        comment['testcase_feedback.0.testcase_name'] = "Wat"
+        comment['testcase_feedback.0.karma'] = -1
         res = self.app.post_json('/comments/', comment)
         self.assertNotIn('errors', res.json_body)
         self.assertIn('comment', res.json_body)
Repository: fedora-infra/bodhi

Issue:
Cannot edit an update without passing notes to it
https://github.com/fedora-infra/bodhi/commit/c70880ce60f0431272d81065c97cd50afdf287f7 made it so that users cannot edit existing updates without providing notes:

```
$ bodhi updates edit --type bugfix erlang-goldrush-0.2.0-1.fc28
ERROR: must specify at least one of --notes, --notes-file
```

This is a 3.9.0 release blocker.


Discussion:

Resolving patch:
diff --git a/bodhi/client/__init__.py b/bodhi/client/__init__.py
--- a/bodhi/client/__init__.py
+++ b/bodhi/client/__init__.py
@@ -370,10 +370,6 @@ def edit(user, password, url, **kwargs):
 
     kwargs['notes'] = _get_notes(**kwargs)
 
-    if not kwargs['notes']:
-        click.echo("ERROR: must specify at least one of --notes, --notes-file")
-        sys.exit(1)
-
     try:
         if re.search(bindings.UPDATE_ID_RE, kwargs['update']):
             query_param = {'updateid': kwargs['update']}


Test patch:
diff --git a/bodhi/tests/client/test___init__.py b/bodhi/tests/client/test___init__.py
--- a/bodhi/tests/client/test___init__.py
+++ b/bodhi/tests/client/test___init__.py
@@ -1405,22 +1405,6 @@ def test_bodhi_client_exception(self, send_request):
         self.assertEqual(result.exit_code, 0)
         self.assertIn("This is a BodhiClientException message", result.output)
 
-    def test_edit_update_without_notes(self):
-        """
-        Assert providing neither --notes-file nor --notes parameters to updates edit request
-        results in an error.
-        """
-        runner = testing.CliRunner()
-
-        result = runner.invoke(
-            client.edit,
-            ['--user', 'bowlofeggs', '--password', 's3kr3t', '--autokarma', 'bodhi-2.2.4-1.el7',
-             '--url', 'http://localhost:6543'])
-
-        self.assertEqual(result.exit_code, 1)
-        self.assertEqual(result.output, u'ERROR: must specify at least one of --notes, '
-                                        '--notes-file\n')
-
 
 class TestEditBuilrootOverrides(unittest.TestCase):
     """
Repository: fedora-infra/bodhi

Issue:
bodhi releases should not prompt for password
The newly added ```bodhi releases``` command group prompts the user for a password if ```--password``` is not used. The CLI will already prompt for a password if one is not given, so this is unnecessary and is actually burdensome when the user already has a cached session token.


Discussion:

Resolving patch:
diff --git a/bodhi/client/__init__.py b/bodhi/client/__init__.py
--- a/bodhi/client/__init__.py
+++ b/bodhi/client/__init__.py
@@ -110,7 +110,7 @@ def _warn_if_url_and_staging_set(ctx, param, value):
 # Common releases options
 release_options = [
     click.option('--username'),
-    click.option('--password', prompt=True, hide_input=True),
+    click.option('--password', hide_input=True),
     click.option('--name', help='Release name (eg: F20)'),
     click.option('--long-name', help='Long release name (eg: "Fedora 20")'),
     click.option('--id-prefix', help='Release prefix (eg: FEDORA)'),


Test patch:
Repository: fedora-infra/bodhi

Issue:
bodhi-check-policies should set up a log handler to silence an error message
From Freenode:

```
<nirik> bowlofeggs: FYI, No handlers could be found for logger "bodhi.server" is being spewed by bodhi-check-policies. 
<puiterwijk> for that, you should just setup handlers...
<puiterwijk> logging.basicConfig(level=logging.INFO)
<nirik> I sent it to dev/null for now 
<puiterwijk> I guess that works
```


Discussion:

Resolving patch:
diff --git a/bodhi/server/scripts/check_policies.py b/bodhi/server/scripts/check_policies.py
--- a/bodhi/server/scripts/check_policies.py
+++ b/bodhi/server/scripts/check_policies.py
@@ -23,11 +23,17 @@
 Ideally, this should be done in a fedmsg consumer but we currently do not have any
 messages in the message bus yet.
 """
+import logging
+
 import click
 
 from bodhi.server import config, initialize_db, models, Session
 
 
+logger = logging.getLogger('check-policies')
+logging.basicConfig(level=logging.INFO)
+
+
 @click.command()
 @click.version_option(message='%(version)s')
 def check():


Test patch:
Repository: fedora-infra/bodhi

Issue:
The captcha does not work under Python 3
@morxa [reported](https://github.com/fedora-infra/bodhi/issues/2700#issuecomment-441245759) that the captcha was not working in Fedora's Bodhi deployment:


![screenshot from 2018-11-23 13-44-15](https://user-images.githubusercontent.com/4573064/48946644-49c14a00-ef26-11e8-9644-130ccf3267e9.png)

It turns out that it does work if Bodhi is run with Python 2, but fails under Python 3. My guess is that there is a ```str```/```bytes``` mismatch somewhere that we need to find and fix.


Discussion:

Resolving patch:
diff --git a/bodhi/server/captcha.py b/bodhi/server/captcha.py
--- a/bodhi/server/captcha.py
+++ b/bodhi/server/captcha.py
@@ -212,7 +212,7 @@ def generate_captcha(context, request):
     """
     settings = request.registry.settings
     plainkey, value = math_generator(plainkey=None, settings=settings)
-    cipherkey = encrypt(plainkey, settings)
+    cipherkey = encrypt(plainkey, settings).decode('utf8')
     url = request.route_url('captcha_image', cipherkey=cipherkey)
     request.session['captcha'] = cipherkey  # Remember this to stop replay.
     return cipherkey, url


Test patch:
diff --git a/bodhi/tests/server/test_captcha.py b/bodhi/tests/server/test_captcha.py
--- a/bodhi/tests/server/test_captcha.py
+++ b/bodhi/tests/server/test_captcha.py
@@ -128,6 +128,7 @@ def test_captcha_can_be_solved(self):
         cipherkey, url = captcha.generate_captcha(None, request)
 
         self.assertEqual(request.session['captcha'], cipherkey)
+        self.assertTrue(isinstance(cipherkey, six.text_type))
         request.route_url.assert_called_once_with('captcha_image', cipherkey=cipherkey)
         self.assertEqual(url, request.route_url.return_value)
         # Let's cheat and find out what the correct value for this cipherkey is and make sure it is
Repository: fedora-infra/bodhi

Issue:
HTTP 500 when viewing composes
I saw this when visiting https://bodhi.fedoraproject.org/composes/ just now:

```
500 Internal Server Error

Traceback (most recent call last): File "/usr/lib/python3.7/site-packages/pyramid_mako/__init__.py", line 148, in __call__ result = template.render_unicode(**system) File "/usr/lib/python3.7/site-packages/mako/template.py", line 471, in render_unicode as_unicode=True) File "/usr/lib/python3.7/site-packages/mako/runtime.py", line 838, in _render **_kwargs_for_callable(callable_, data)) File "/usr/lib/python3.7/site-packages/mako/runtime.py", line 873, in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File "/usr/lib/python3.7/site-packages/mako/runtime.py", line 899, in _exec_template callable_(context, *args, **kwargs) File "/usr/lib/python3.7/site-packages/bodhi/server/templates/master.html", line 189, in render_body ${self.body()} File "/usr/lib/python3.7/site-packages/bodhi/server/templates/composes.html", line 19, in render_body ${ self.util.composestate2html(compose.state) | n } File "/usr/lib/python3.7/site-packages/bodhi/server/util.py", line 525, in composestate2html }[state.value] KeyError: 'syncing_repo'
```


Discussion:

Resolving patch:
diff --git a/bodhi/server/util.py b/bodhi/server/util.py
--- a/bodhi/server/util.py
+++ b/bodhi/server/util.py
@@ -510,6 +510,8 @@ def composestate2html(context, state):
         'punging': 'warning',
         'notifying': 'warning',
         'cleaning': 'warning',
+        'syncing_repo': 'warning',
+        'signing_repo': 'warning',
         'success': 'success',
         'failed': 'danger',
     }[state.value]


Test patch:
diff --git a/bodhi/tests/server/test_util.py b/bodhi/tests/server/test_util.py
--- a/bodhi/tests/server/test_util.py
+++ b/bodhi/tests/server/test_util.py
@@ -468,6 +468,18 @@ def test_cleaning(self):
         self.assertEqual(util.composestate2html(None, ComposeState.cleaning),
                          "<span class='label label-warning'>Cleaning old composes</span>")
 
+    def test_syncing_repo(self):
+        """Assert correct return value with the syncing_repo state."""
+        self.assertEqual(
+            util.composestate2html(None, ComposeState.syncing_repo),
+            "<span class='label label-warning'>Wait for the repo to hit the master mirror</span>",
+        )
+
+    def test_signing_repo(self):
+        """Assert correct return value with the signing_repo state."""
+        self.assertEqual(util.composestate2html(None, ComposeState.signing_repo),
+                         "<span class='label label-warning'>Signing repo</span>")
+
 
 class TestCanWaiveTestResults(base.BaseTestCase):
     """Test the can_waive_test_results() function."""
Repository: fedora-infra/bodhi

Issue:
Kill the /masher view
If #2022 did not use the same endpoint, we should delete the ```/masher``` endpoint. If it did use that same endpoint, we can close this ticket.

Depends on #2022.


Discussion:

Resolving patch:
diff --git a/bodhi/server/__init__.py b/bodhi/server/__init__.py
--- a/bodhi/server/__init__.py
+++ b/bodhi/server/__init__.py
@@ -286,7 +286,6 @@ def main(global_config, testing=None, session=None, **settings):
 
     # Metrics
     config.add_route('metrics', '/metrics')
-    config.add_route('masher_status', '/masher/')
 
     # Auto-completion search
     config.add_route('search_packages', '/search/packages')
diff --git a/bodhi/server/views/generic.py b/bodhi/server/views/generic.py
--- a/bodhi/server/views/generic.py
+++ b/bodhi/server/views/generic.py
@@ -337,19 +337,6 @@ def latest_builds(request):
     return builds
 
 
-@view_config(route_name='masher_status', renderer='masher.html')
-def masher_status(request):
-    """
-    Return the masher status page.
-
-    Args:
-        request (pyramid.util.Request): The current request. Unused.
-    Returns:
-        dict: An empty dictionary.
-    """
-    return dict()
-
-
 @view_config(route_name='new_override', renderer='override.html')
 def new_override(request):
     """


Test patch:
diff --git a/bodhi/tests/server/views/test_generic.py b/bodhi/tests/server/views/test_generic.py
--- a/bodhi/tests/server/views/test_generic.py
+++ b/bodhi/tests/server/views/test_generic.py
@@ -340,11 +340,6 @@ def test_version(self):
         res = self.app.get('/api_version')
         self.assertIn('version', res.json_body)
 
-    def test_masher_status(self):
-        """Test that the masher status page displays"""
-        res = self.app.get('/masher/')
-        self.assertIn('<h1>Bodhi Masher Activity</h1>', res)
-
     def test_popup_toggle(self):
         """Check that the toggling of pop-up notifications works"""
         # first we check that popups are enabled by default
Repository: fedora-infra/bodhi

Issue:
The sqlalchemy.url setting should default to PostgreSQL
Since Bodhi only works with PostgreSQL, we should default the ```sqlalchemy.url``` setting to it. Here's what might be a same default:

```
postgresql://localhost/bodhi
```

Of course, any sane sysadmin should adjust this setting anyway, but it would be better if we defaulted to postgres instead of sqlite.


Discussion:

Resolving patch:
diff --git a/bodhi/server/config.py b/bodhi/server/config.py
--- a/bodhi/server/config.py
+++ b/bodhi/server/config.py
@@ -585,7 +585,7 @@ class BodhiConfig(dict):
             'value': None,
             'validator': _validate_none_or(str)},
         'sqlalchemy.url': {
-            'value': 'sqlite:////var/cache/bodhi.db',
+            'value': 'postgresql://localhost/bodhi',
             'validator': str},
         'stable_bug_msg': {
             'value': ('%s has been pushed to the %s repository. If problems still persist, please '


Test patch:
Repository: fedora-infra/bodhi

Issue:
bodhi.server.services.updates.new_update() has an assert statement
There is an [```assert``` statement](https://github.com/fedora-infra/bodhi/blob/3.11.3/bodhi/server/services/updates.py#L507) in ```bodhi.server.services.updates.new_update()```. This assert looks like it might be important for correct operation, but the problem is that assert statements get stripped out of optimized Python builds (so the statement won't be present in production).


Discussion:
After some investigation, I think that it is impossible to reach this line because of:
https://github.com/fedora-infra/bodhi/blob/d1600a16e9bdeeaed9d454f9668010ab8c179511/bodhi/server/validators.py#L306

Related UT:
https://github.com/fedora-infra/bodhi/blob/d1600a16e9bdeeaed9d454f9668010ab8c179511/bodhi/tests/server/services/test_updates.py#L2970

To substitute "assert statement", we can raise BodhiException(with the assert statment  info) in the same place(and add "catch" snippet couple lines after), but without unittest.
@bowlofeggs What do you think?
@sebwoj yeah that seems solid to me. I think we can just drop the ```assert``` statement.

Resolving patch:
diff --git a/bodhi/server/services/updates.py b/bodhi/server/services/updates.py
--- a/bodhi/server/services/updates.py
+++ b/bodhi/server/services/updates.py
@@ -485,7 +485,6 @@ def new_update(request):
 
             log.info('Editing update: %s' % data['edited'])
 
-            assert len(releases) == 1, "Updates may not span multiple releases"
             data['release'] = list(releases)[0]
             data['builds'] = [b.nvr for b in builds]
             result, _caveats = Update.edit(request, data)


Test patch: