Error in Auditory


#1

I have a problem in the audit option, if the users’ names are very long then their operations are not displayed.
The following error appears. I guess I’ll have to increase the size of the “user” field, but HOW?
Thank you

						     
[2018-06-22 14:41:00,629][56864][140355808794432][ERROR][privacyidea.lib.auditmodules.sqlaudit:240] exception DataError('(_mysql_exceptions.DataError) (1406, "Data too long for column \'user\' at row 1")',)
[2018-06-22 14:41:00,629][56864][140355808794432][ERROR][privacyidea.lib.auditmodules.sqlaudit:241] DATA: {'info': '', 'realm': u'dominio-oidpruebas', 'success': True, 'privacyidea_server': 'cas1-pre.ti.uam.es:5001', 'client_user_agent': 'firefox', 'token_type': None, 'client': '150.244.212.154', 'user': u'coco.liso@externo.uam.es', 'resolver': u'PRUEBAS-EXTERNOS', 'action_detail': '', 'action': 'GET /audit/', 'serial': u'**'}
[2018-06-22 14:41:00,630][56864][140355808794432][DEBUG][privacyidea.lib.auditmodules.sqlaudit:242] Traceback (most recent call last):
  File "/opt/privacyidea/lib/python2.7/site-packages/privacyidea/lib/auditmodules/sqlaudit.py", line 231, in finalize_log
    self.session.commit()
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 943, in commit
    self.transaction.commit()
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 467, in commit
    self._prepare_impl()
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 447, in _prepare_impl
    self.session.flush()
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2254, in flush
    self._flush(objects)
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2380, in _flush
    transaction.rollback(_capture_exception=True)
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2344, in _flush
    flush_context.execute()
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 391, in execute
    rec.execute(self)
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 556, in execute
    uow
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
    mapper, table, insert)
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 866, in _emit_insert_statements
    execute(statement, params)
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/opt/privacyidea/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
  File "/opt/privacyidea/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/opt/privacyidea/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
DataError: (_mysql_exceptions.DataError) (1406, "Data too long for column 'user' at row 1") [SQL: u'INSERT INTO pidea_audit (date, signature, action, success, serial, token_type, user, realm, resolver, administrator, action_detail, info, privacyidea_server, client, loglevel, clearance_level) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'] [parameters: (datetime.datetime(2018, 6, 22, 14, 41, 0, 614253), '', 'GET /audit/', 1, u'**', None, u'coco.liso@externo.uam.es', u'dominio-oidpruebas', u'PRUEBAS-EXTERNOS', None, '', '', 'cas1-pre.ti.uam.es:5001', '150.244.212.154', None, None)] (Background on this error at: http://sqlalche.me/e/9h9h)

#2

You can also try to use the SQL TRUNCATE option in the pi.cfg file.

This will cut the values in the audit log to the maximum length of the DB column.


#3

OK. Thank you. It works as I wanted.
Thank you.