getredash / redash

Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.
http://redash.io/
BSD 2-Clause "Simplified" License
25.5k stars 4.31k forks source link

Error when granting Admin to user via checkbox in user's Settings tab #862

Closed michael-go closed 8 years ago

michael-go commented 8 years ago

The stack trace from the server:

[2016-02-27 21:04:04,817][PID:20520][ERROR][peewee] UPDATE "users" SET "updated_at" = %s, "name" = %s, "email" = %s, "groups" = %s WHERE ("users"."id" = %s) [datetime.datetime(2016, 2, 27, 21, 4, 4, 816712), u'koko', u'koko@moko.co', [2, u'admin'], 3]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/playhouse/postgres_ext.py", line 360, in execute_sql
    cursor.execute(sql, params or ())
DataError: invalid input syntax for integer: "admin"
LINE 1: ...email" = 'koko@moko.co', "groups" = ARRAY[2, 'admin'] W...
                                                             ^

[2016-02-27 21:04:04,818][PID:20520][ERROR][redash.wsgi] Exception on /api/users/3 [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.7/dist-packages/flask_restful/__init__.py", line 477, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/flask_login.py", line 792, in decorated_view
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/flask/views.py", line 84, in view
    return self.dispatch_request(*args, **kwargs)
  File "/opt/redash/current/redash/handlers/base.py", line 19, in dispatch_request
    return super(BaseResource, self).dispatch_request(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/flask_restful/__init__.py", line 587, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/opt/redash/current/redash/handlers/users.py", line 76, in post
    user.update_instance(**params)
  File "/opt/redash/current/redash/models.py", line 106, in update_instance
    self.save(only=self.dirty_fields)
  File "/opt/redash/current/redash/models.py", line 93, in save
    super(BaseModel, self).save(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 4146, in save
    rows = self.update(**field_dict).where(self._pk_expr()).execute()
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2751, in execute
    return self.database.rows_affected(self._execute())
  File "/opt/redash/current/redash/metrics/database.py", line 50, in metered_execute
    result = real_execute(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2371, in _execute
    return self.database.execute_sql(sql, params, self.require_commit)
  File "/opt/redash/current/redash/metrics/database.py", line 22, in execute_sql
    result = super(MeteredPostgresqlExtDatabase, self).execute_sql(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/playhouse/postgres_ext.py", line 369, in execute_sql
    self.commit()
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2922, in __exit__
    reraise(new_type, new_type(*exc_value.args), traceback)
  File "/usr/local/lib/python2.7/dist-packages/playhouse/postgres_ext.py", line 360, in execute_sql
    cursor.execute(sql, params or ())
DataError: invalid input syntax for integer: "admin"
LINE 1: ...email" = 'koko@moko.co', "groups" = ARRAY[2, 'admin'] W...

It is still possible to grant admin privileges using the UI by adding the user to the admin group though.

Thanks

michael-go commented 8 years ago

oops i just saw its a duplicate with https://github.com/getredash/redash/issues/785