Repository: ericsson/codechecker
Issue: Error writing to mysql database

```
[ERROR] [12:29] - This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (sqlite3.ProgrammingError) You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. [SQL: u'UPDATE build_actions SET failure_txt=?, duration=? WHERE build_actions.id = ?'] [parameters: ("In file included from /mypath_replaced/SystemCall.cpp:1:\\nIn file included from ../../libes10_framework/include/libes10_framework/utils/SystemCall.h:8:\\nIn file included from ../../libes10_framework/include/libes10_framework/data/exceptions/Exception.h:7:\\nIn file included from /mypath_replaced/Log_Msg.h:751:\\nIn file included from /mypath_replaced/Log_Msg.inl:5:\\nIn file included from /mypath_replaced/OS_NS_string.h:473:\\n/mypath_replaced/OS_NS_string.inl:110:10: warning: Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119\\n  return ::strcat (s, t);\\n         ^~~~~~~~\\n/mypath_replaced/OS_NS_string.inl:178:10: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119\\n  return ::strcpy (s, t);\\n         ^~~~~~~~\\nIn file included from /mypath_replaced/SystemCall.cpp:1:\\nIn file included from ../../libes10_framework/include/libes10_framework/utils/SystemCall.h:8:\\nIn file included from ../../libes10_framework/include/libes10_framework/data/exceptions/Exception.h:7:\\nIn file included from /mypath_replaced/Log_Msg.h:751:\\nIn file included from /mypath_replaced/Log_Msg.inl:6:\\nIn file included from /mypath_replaced/OS_NS_unistd.h:371:\\nIn file included from /mypath_replaced/OS_NS_unistd.inl:11:\\nIn file included from /mypath_replaced/OS_Memory.h:337:\\nIn file included from /mypath_replaced/OS_NS_stdlib.h:449:\\n/mypath_replaced/OS_NS_stdlib.inl:277:10: warning: Call to function 'mktemp' is insecure as it always creates or uses insecure temporary file.  Use 'mkstemp' instead\\n  return ::mktemp (s);\\n         ^~~~~~~~\\n/mypath_replaced/OS_NS_stdlib.inl:292:7: warning: Call to function 'mktemp' is insecure as it always creates or uses insecure temporary file.  Use 'mkstemp' instead\\n  if (::mktemp (narrow_s.char_rep ()) == 0)\\n      ^~~~~~~~\\nIn file included from /mypath_replaced/SystemCall.cpp:1:\\nIn file included from ../../libes10_framework/include/libes10_framework/utils/SystemCall.h:9:\\nIn file included from ../../libes10_framework/include/libes10_framework/interfaces/command/CommandData.h:3:\\nIn file included from /mypath_replaced/Recursive_Thread_Mutex.h:31:\\nIn file included from /mypath_replaced/OS_NS_Thread.h:2049:\\nIn file included from /mypath_replaced/OS_NS_Thread.inl:8:\\nIn file included from /mypath_replaced/OS_NS_sys_mman.h:93:\\nIn file included from /mypath_replaced/OS_NS_sys_mman.inl:7:\\nIn file included from /mypath_replaced/OS_NS_stdio.h:560:\\n/mypath_replaced/OS_NS_stdio.inl:439:14: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119\\n      return ACE_OS::strcpy (userid, pw->pw_name);\\n             ^~~~~~~~~~~~~~\\n/mypath_replaced/SystemCall.cpp:47:3: warning: Call to virtual function during construction will not dispatch to derived class\\n  this->reactor(new ACE_Reactor());\\n  ^~~~~~~~~~~~~\\n/mypath_replaced/SystemCall.cpp:51:3: warning: Call to virtual function during construction will not dispatch to derived class\\n  this->reactor()->timer_queue()->gettimeofday( &SystemTimeInfo::getSystemUpTime_static );\\n  ^~~~~~~~~~~~~\\n/mypath_replaced/SystemCall.cpp:69:10: warning: Call to virtual function during destruction will not dispatch to derived class\\n  delete this->reactor();\\n         ^~~~~~~~~~~~~\\n/mypath_replaced/SystemCall.cpp:70:3: warning: Call to virtual function during destruction will not dispatch to derived class\\n  reactor(0);//Damit wir untul\\xc3\\xa4ssige Zugriffe schneller finden!\\n  ^~~~~~~\\n9 warnings generated.\\n", 0.710736, 230)]
Traceback (most recent call last):
  File "/usr/local/src/codechecker/build/CodeChecker/lib/python2.7/libcodechecker/analyze/analysis_manager.py", line 135, in check
    rh.handle_results()
  File "/usr/local/src/codechecker/build/CodeChecker/lib/python2.7/libcodechecker/analyze/analyzers/result_handler_plist_to_db.py", line 154, in handle_results
    source_file_name)
  File "/usr/local/src/codechecker/build/CodeChecker/lib/python2.7/libcodechecker/client.py", line 170, in add_build_action
    analyzed_source_file)
  File "/usr/local/src/codechecker/build/CodeChecker/lib/python2.7/gencodechecker/DBThriftAPI/CheckerReport.py", line 314, in addBuildAction
    return self.recv_addBuildAction()
  File "/usr/local/src/codechecker/build/CodeChecker/lib/python2.7/gencodechecker/DBThriftAPI/CheckerReport.py", line 341, in recv_addBuildAction
    raise result.requestError
RequestFailed: RequestFailed(_message='This Session\\'s transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (sqlite3.ProgrammingError) You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. [SQL: u\\'UPDATE build_actions SET failure_txt=?, duration=? WHERE build_actions.id = ?\\'] [parameters: ("In file included from /mypath_replaced/SystemCall.cpp:1:\\\\nIn file included from ../../libes10_framework/include/libes10_framework/utils/SystemCall.h:8:\\\\nIn file included from ../../libes10_framework/include/libes10_framework/data/exceptions/Exception.h:7:\\\\nIn file included from /mypath_replaced/Log_Msg.h:751:\\\\nIn file included from /mypath_replaced/Log_Msg.inl:5:\\\\nIn file included from /mypath_replaced/OS_NS_string.h:473:\\\\n/mypath_replaced/OS_NS_string.inl:110:10: warning: Call to function \\'strcat\\' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as \\'strlcat\\'. CWE-119\\\\n  return ::strcat (s, t);\\\\n         ^~~~~~~~\\\\n/mypath_replaced/OS_NS_string.inl:178:10: warning: Call to function \\'strcpy\\' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as \\'strlcpy\\'. CWE-119\\\\n  return ::strcpy (s, t);\\\\n         ^~~~~~~~\\\\nIn file included from /mypath_replaced/SystemCall.cpp:1:\\\\nIn file included from ../../libes10_framework/include/libes10_framework/utils/SystemCall.h:8:\\\\nIn file included from ../../libes10_framework/include/libes10_framework/data/exceptions/Exception.h:7:\\\\nIn file included from /mypath_replaced/Log_Msg.h:751:\\\\nIn file included from /mypath_replaced/Log_Msg.inl:6:\\\\nIn file included from /mypath_replaced/OS_NS_unistd.h:371:\\\\nIn file included from /mypath_replaced/OS_NS_unistd.inl:11:\\\\nIn file included from /mypath_replaced/OS_Memory.h:337:\\\\nIn file included from /mypath_replaced/OS_NS_stdlib.h:449:\\\\n/mypath_replaced/OS_NS_stdlib.inl:277:10: warning: Call to function \\'mktemp\\' is insecure as it always creates or uses insecure temporary file.  Use \\'mkstemp\\' instead\\\\n  return ::mktemp (s);\\\\n         ^~~~~~~~\\\\n/mypath_replaced/OS_NS_stdlib.inl:292:7: warning: Call to function \\'mktemp\\' is insecure as it always creates or uses insecure temporary file.  Use \\'mkstemp\\' instead\\\\n  if (::mktemp (narrow_s.char_rep ()) == 0)\\\\n      ^~~~~~~~\\\\nIn file included from /mypath_replaced/SystemCall.cpp:1:\\\\nIn file included from ../../libes10_framework/include/libes10_framework/utils/SystemCall.h:9:\\\\nIn file included from ../../libes10_framework/include/libes10_framework/interfaces/command/CommandData.h:3:\\\\nIn file included from /mypath_replaced/Recursive_Thread_Mutex.h:31:\\\\nIn file included from /mypath_replaced/OS_NS_Thread.h:2049:\\\\nIn file included from /mypath_replaced/OS_NS_Thread.inl:8:\\\\nIn file included from /mypath_replaced/OS_NS_sys_mman.h:93:\\\\nIn file included from /mypath_replaced/OS_NS_sys_mman.inl:7:\\\\nIn file included from /mypath_replaced/OS_NS_stdio.h:560:\\\\n/mypath_replaced/OS_NS_stdio.inl:439:14: warning: Call to function \\'strcpy\\' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as \\'strlcpy\\'. CWE-119\\\\n      return ACE_OS::strcpy (userid, pw->pw_name);\\\\n             ^~~~~~~~~~~~~~\\\\n/mypath_replaced/SystemCall.cpp:47:3: warning: Call to virtual function during construction will not dispatch to derived class\\\\n  this->reactor(new ACE_Reactor());\\\\n  ^~~~~~~~~~~~~\\\\n/mypath_replaced/SystemCall.cpp:51:3: warning: Call to virtual function during construction will not dispatch to derived class\\\\n  this->reactor()->timer_queue()->gettimeofday( &SystemTimeInfo::getSystemUpTime_static );\\\\n  ^~~~~~~~~~~~~\\\\n/mypath_replaced/SystemCall.cpp:69:10: warning: Call to virtual function during destruction will not dispatch to derived class\\\\n  delete this->reactor();\\\\n         ^~~~~~~~~~~~~\\\\n/mypath_replaced/SystemCall.cpp:70:3: warning: Call to virtual function during destruction will not dispatch to derived class\\\\n  reactor(0);//Damit wir untul\\\\xc3\\\\xa4ssige Zugriffe schneller finden!\\\\n  ^~~~~~~\\\\n9 warnings generated.\\\\n", 0.710736, 230)]', error_code=0)

```
If more information is needed, please let me know. I will try to come up with it.

Changed files:
libcodechecker/storage/report_server.py

diff --git a/libcodechecker/storage/report_server.py b/libcodechecker/storage/report_server.py
index 9b5cd12a..8521ee7e 100644
--- a/libcodechecker/storage/report_server.py
+++ b/libcodechecker/storage/report_server.py
@@ -277,6 +277,8 @@ class CheckerReportHandler(object):
             # TODO: if file is not needed update reportsToBuildActions.
             return False
 
+        failure = failure.decode('unicode_escape').encode('ascii', 'ignore')
+
         action.mark_finished(failure)
         self.session.commit()
         return True