nylas / sync-engine

:incoming_envelope: IMAP/SMTP sync system with modern APIs
https://nylas.com/docs/platform
GNU Affero General Public License v3.0
3.5k stars 354 forks source link

Error when adding a mailbox #387

Closed cdalbergue closed 8 years ago

cdalbergue commented 8 years ago

Hi everyone, I am running into this issue when trying to add an account. It seems that my gmail token id is too long for the database. I have tried to modify the column from varchar(1024) to varchar(2048) but it doesn't work.

Has anyone any of the same trouble ? Have ou fixed it yet ?

[INFO] Starting new HTTPS connection (1): www.googleapis.com
[DEBUG] "POST /oauth2/v4/token HTTP/1.1" 200 None
[INFO] Starting new HTTPS connection (1): www.googleapis.com
[DEBUG] "GET /oauth2/v2/tokeninfo?access_token=REDACTED HTTP/1.1" 200 None
[INFO] Starting new HTTPS connection (1): www.googleapis.com
[DEBUG] "GET /oauth2/v1/userinfo?access_token=REDACTED HTTP/1.1" 200 None
[INFO] Starting new HTTPS connection (1): www.googleapis.com
[DEBUG] "POST /oauth2/v4/token HTTP/1.1" 200 None
[WARNING] {"latency": 38643, "modname": "__main__", "level": "warning", "timestamp": "2016-08-30T20:35:42.690630Z", "module": "__main__:62", "funcname": "main", "greenlet_id": 130305448006352, "event": "Long transaction"}
Traceback (most recent call last):
  File "bin/inbox-auth", line 69, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 488, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 474, in main
    self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 659, in invoke
    ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 325, in invoke
    return callback(*args, **kwargs)
  File "bin/inbox-auth", line 62, in main
    db_session.commit()
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 801, in commit
    self.transaction.commit()
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 392, in commit
    self._prepare_impl()
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 372, in _prepare_impl
    self.session.flush()
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2019, in flush
    self._flush(objects)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2137, in _flush
    transaction.rollback(_capture_exception=True)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2101, in _flush
    flush_context.execute()
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 373, in execute
    rec.execute(self)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 532, in execute
    uow
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 174, in save_obj
    mapper, table, insert)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 800, in _emit_insert_statements
    execute(statement, params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 914, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
    context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
    exc_info
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 202, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 450, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 226, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorvalue
sqlalchemy.exc.DataError: (_mysql_exceptions.DataError) (1406, "Data too long for column 'g_id_token' at row 1") [SQL: u'INSERT INTO gmailauthcredentials (created_at, updated_at, deleted_at, gmailaccount_id, refresh_token_id, scopes, g_id_token, client_id, client_secret, is_valid) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'] [parameters: (datetime.datetime(2016, 8, 30, 20, 35, 42, 661802), datetime.datetime(2016, 8, 30, 20, 35, 42, 661833), None, 6L, 12L, u'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://mail.google.com/ https://www.google.com/m8/feeds https://www.googleapis.com/auth/calendar', u'REDACTED', 'REDACTED, 'REDACTED', 1)]
clement@ns320463:~/nylas/sync-engine$ 
pfista commented 8 years ago

Thanks for reporting this! I've edited your comment to remove sensitive information. Be careful next time!

Fixed in 469b463de25fa904fd1dfce001e558920e7f6e5b

cdalbergue commented 8 years ago

Hey @pfista, thanks for removing these infos from my comment, I thaught of it 5 minutes ago, was going to do it myself.

I've looked into your fix, but I didn't try it yet. Are you sure this is going to work ? I have changed the database column property manually via mysql and it still didn't work. I'll edit this message after testing.

Edit

Well I've just seen that a test was failing, forget what I said, keep up the good work