Last Comment Bug 1297765 - cannot add permissions that don't have options set
: cannot add permissions that don't have options set
Status: RESOLVED FIXED
:
Product: Release Engineering
Classification: Other
Component: Balrog: Backend (show other bugs)
: unspecified
: Unspecified Unspecified
-- normal (vote)
: ---
Assigned To: Ben Hearsum (:bhearsum)
: Ben Hearsum (:bhearsum)
:
Mentors:
Depends on: 1302450
Blocks:
  Show dependency treegraph
 
Reported: 2016-08-24 10:42 PDT by Ben Hearsum (:bhearsum)
Modified: 2016-09-14 13:10 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
fix default value for options (42 bytes, text/x-github-pull-request)
2016-09-01 09:48 PDT, Ben Hearsum (:bhearsum)
rail: review+
Details | Review | Splinter Review

Description User image Ben Hearsum (:bhearsum) 2016-08-24 10:42:30 PDT
Rail noticed this while trying to grant Johan admin permissions. In production, it shows up as a 502 (which is a bit strange). I was able to reproduce locally, and got:
balrogadmin_1 | 2016-08-24 17:37:02,995 - DEBUG - PID: 102 - Request: 139838539774992 - Permissions.insert#1657: granting admin to foobar with options {}
balrogadmin_1 | Traceback (most recent call last):
balrogadmin_1 |   File "./auslib/admin/views/base.py", line 69, in put
balrogadmin_1 |     return self._put(*args, transaction=trans, **kwargs)
balrogadmin_1 |   File "./auslib/admin/views/base.py", line 19, in decorated
balrogadmin_1 |     return f(*args, changed_by=username, **kwargs)
balrogadmin_1 |   File "./auslib/admin/views/permissions.py", line 57, in _put
balrogadmin_1 |     dbo.permissions.insert(changed_by, transaction=transaction, username=username, permission=permission, options=form.options.data)
balrogadmin_1 |   File "./auslib/db.py", line 1658, in insert
balrogadmin_1 |     super(Permissions, self).insert(changed_by=changed_by, transaction=transaction, **columns)
balrogadmin_1 |   File "./auslib/db.py", line 325, in insert
balrogadmin_1 |     return self._prepareInsert(transaction, changed_by, **columns)
balrogadmin_1 |   File "./auslib/db.py", line 301, in _prepareInsert
balrogadmin_1 |     ret = trans.execute(query)
balrogadmin_1 |   File "./auslib/db.py", line 122, in execute
balrogadmin_1 |     return self.conn.execute(statement)
balrogadmin_1 |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1358, in execute
balrogadmin_1 |     params)
balrogadmin_1 |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1491, in _execute_clauseelement
balrogadmin_1 |     compiled_sql, distilled_params
balrogadmin_1 |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1599, in _execute_context
balrogadmin_1 |     context)
balrogadmin_1 |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1592, in _execute_context
balrogadmin_1 |     context)
balrogadmin_1 |   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 325, in do_execute
balrogadmin_1 |     cursor.execute(statement, parameters)
balrogadmin_1 |   File "/usr/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
balrogadmin_1 |     self.errorhandler(self, exc, value)
balrogadmin_1 |   File "/usr/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
balrogadmin_1 |     raise errorclass, errorvalue
balrogadmin_1 | TransactionError: ('(ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'}, 1)\' at line 1")',)


If I hack the code and remove "options" from what's about to get inserted, it works fine. Without that hack, I can still add permissions as long as they have "options" set.

This is likely a regression from https://bugzilla.mozilla.org/show_bug.cgi?id=1246675.
Comment 1 User image Ben Hearsum (:bhearsum) 2016-09-01 09:48:42 PDT
Created attachment 8787285 [details] [review]
fix default value for options
Comment 2 User image Rail Aliiev [:rail] ⌚️ET 2016-09-01 10:05:35 PDT
Comment on attachment 8787285 [details] [review]
fix default value for options

lgtm
Comment 3 User image [github robot] 2016-09-02 11:05:42 PDT
Commit pushed to master at https://github.com/mozilla/balrog

https://github.com/mozilla/balrog/commit/49dd520555c18d68b4f11c4c29b5c07849095452
bug 1297765: Use different default value for permission options. (#117). r=rail
Comment 4 User image Ben Hearsum (:bhearsum) 2016-09-14 13:10:36 PDT
This made it to production today.

Note You need to log in before you can comment on or make changes to this bug.