Repository: fedora-infra/bodhi

Issue:
Editing an update using CLI sets type to 'bugfix' if not provided
While editing an update using CLI, if we don't provide the update type, it will modify it to ```bugfix```

So if we edit a ```security``` update, 

```bodhi updates edit --severity low moin-1.9.9-1.el6```

update's type will be changed to ```bugfix```. I think [this](https://github.com/fedora-infra/bodhi/blob/develop/bodhi/client/__init__.py#L96) might be the reason, as the default is shared between create and edit update.


Discussion:
Was this not fixed by https://github.com/fedora-infra/bodhi/pull/2464 ? If not, was it caused by it? Is this a regression in 3.9, or was it present before?
@bowlofeggs: Neither. This bug is logically different from #2464. It was present before as there is a common default option in CLI for creating/editing update. I think a simple fix will be moving ```--type``` out of the common options [here](https://github.com/fedora-infra/bodhi/blob/develop/bodhi/client/__init__.py#L96). But it will move it to either top or bottom in the ```--help``` section.
I have confirmed that this issue is present in Bodhi 3.8, so I will degrade its priority to high and will not consider it a 3.9 release blocker.

Resolving patch:
diff --git a/bodhi/client/__init__.py b/bodhi/client/__init__.py
--- a/bodhi/client/__init__.py
+++ b/bodhi/client/__init__.py
@@ -93,8 +93,6 @@ def _set_logging_debug(ctx, param, value):
 new_edit_options = [
     click.option('--user'),
     click.option('--password', hide_input=True),
-    click.option('--type', default='bugfix', help='Update type', required=True,
-                 type=click.Choice(['security', 'bugfix', 'enhancement', 'newpackage'])),
     click.option('--severity', help='Update severity',
                  type=click.Choice(['unspecified', 'low', 'medium', 'high', 'urgent']),
                  is_eager=True),
@@ -353,6 +351,8 @@ def require_severity_for_security_update(type, severity):
 
 
 @updates.command()
+@click.option('--type', default='bugfix', help='Update type', required=True,
+              type=click.Choice(['security', 'bugfix', 'enhancement', 'newpackage']))
 @add_options(new_edit_options)
 @click.argument('builds')
 @click.option('--file', help='A text file containing all the update details')
@@ -426,6 +426,8 @@ def _validate_edit_update(ctx, param, value):
 
 
 @updates.command()
+@click.option('--type', help='Update type',
+              type=click.Choice(['security', 'bugfix', 'enhancement', 'newpackage']))
 @add_options(new_edit_options)
 @click.argument('update', callback=_validate_edit_update)
 @url_option


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
@@ -1420,7 +1420,7 @@ def test_bugs_flag(self, send_request, query):
                     'autokarma': False, 'edited': 'nodejs-grunt-wrap-0.3.0-2.fc25',
                     'suggest': 'unspecified', 'notes': 'New package.',
                     'notes_file': None, 'request': None, 'unstable_karma': -3,
-                    'bugs': '1234,5678', 'requirements': '', 'type': 'bugfix',
+                    'bugs': '1234,5678', 'requirements': '', 'type': 'newpackage',
                     'severity': 'low'}),
             mock.call(
                 bindings_client,
@@ -1457,7 +1457,8 @@ def test_severity_flag(self, send_request, query):
                     'autokarma': False, 'edited': u'nodejs-grunt-wrap-0.3.0-2.fc25',
                     'suggest': u'unspecified', 'notes': u'Updated package.',
                     'notes_file': None, 'request': None, 'unstable_karma': -3,
-                    'bugs': '1420605', 'requirements': u'', 'type': 'bugfix', 'severity': u'low'
+                    'bugs': '1420605', 'requirements': u'', 'type': 'newpackage',
+                    'severity': u'low'
                 }
             ),
             mock.call(
@@ -1499,7 +1500,8 @@ def test_url_flag(self, send_request, query):
                     'autokarma': False, 'edited': u'nodejs-grunt-wrap-0.3.0-2.fc25',
                     'suggest': u'unspecified', 'notes': u'this is an edited note',
                     'notes_file': None, 'request': None, 'severity': u'low',
-                    'bugs': '1420605', 'requirements': u'', 'unstable_karma': -3, 'type': 'bugfix'
+                    'bugs': '1420605', 'requirements': u'', 'unstable_karma': -3,
+                    'type': 'newpackage'
                 }
             ),
             mock.call(
@@ -1547,7 +1549,7 @@ def test_notes_file(self, send_request, query):
                         'suggest': 'unspecified', 'notes': 'This is a --notes-file note!',
                         'notes_file': 'notefile.txt', 'request': None, 'severity': 'low',
                         'bugs': '1420605', 'requirements': u'', 'unstable_karma': -3,
-                        'type': 'bugfix'
+                        'type': 'newpackage'
                     }
                 ),
                 mock.call(
@@ -1605,7 +1607,8 @@ def test_update_title(self, send_request, query):
                     'autokarma': False, 'edited': u'drupal7-i18n-1.17-1.fc26',
                     'suggest': u'unspecified', 'notes': u'this is an edited note',
                     'notes_file': None, 'request': None, 'bugs': '1420605',
-                    'unstable_karma': -3, 'type': 'bugfix', 'severity': u'low', 'requirements': u''
+                    'unstable_karma': -3, 'type': 'newpackage', 'severity': u'low',
+                    'requirements': u''
                 }
             ),
             mock.call(
@@ -1698,7 +1701,7 @@ def test_required_tasks(self, send_request, query):
                     'suggest': u'unspecified', 'notes': u'testing required tasks',
                     'notes_file': None, 'request': None, 'severity': u'low',
                     'bugs': '1420605', 'unstable_karma': -3,
-                    'requirements': u'dist.depcheck dist.rpmdeplint', 'type': 'bugfix'
+                    'requirements': u'dist.depcheck dist.rpmdeplint', 'type': 'newpackage'
                 }
             ),
             mock.call(
@@ -1757,7 +1760,7 @@ def test_edit_bugless_update_without_bugs_param(self, send_request, query):
                     'autokarma': False, 'edited': u'nodejs-grunt-wrap-0.3.0-2.fc25',
                     'suggest': u'unspecified', 'notes': u'New package.',
                     'notes_file': None, 'request': None, 'severity': u'low',
-                    'bugs': '', 'requirements': u'', 'unstable_karma': -3, 'type': 'bugfix'
+                    'bugs': '', 'requirements': u'', 'unstable_karma': -3, 'type': 'newpackage'
                 }
             ),
             mock.call(