zilch icon indicating copy to clipboard operation
zilch copied to clipboard

StatementError: 'utf8' codec can't decode byte 0xff ... in zilch.client.send

Open mgedmin opened this issue 12 years ago • 1 comments

Just saw this in my error log. It looks like one of the stack frames contained a local variable with binary data (the contents of the uploaded image file, as it happens) and Zilch tried to stuff it into an SQLite column without appropriate escaping?

The full Zilch exception is nearly 400K long and contains the sql statement and the data. I'll try to reproduce with a smaller example.

mgedmin avatar Feb 17 '12 20:02 mgedmin

I've a failing test that reproduces this:

diff --git a/zilch/tests/test_store.py b/zilch/tests/test_store.py
index 8606f65..d05ecac 100644
--- a/zilch/tests/test_store.py
+++ b/zilch/tests/test_store.py
@@ -33,18 +33,19 @@ class TestEventRecord(TestStore):
         with patch('zilch.client.send') as mock_send:
             cap = self._makeCapture()                        
             try:
+                barney = '\xff'
                 fred = smith['no_name']
             except:
                 cap()
             kwargs = mock_send.call_args[1]
-        
+
+        Session = self._makeSession()
         try:
             # For the simplejson serialization that happens
             jsonified = simplejson.loads(simplejson.dumps(kwargs))
             store.message_received(jsonified)
             store.flush()
-        
-            Session = self._makeSession()
+
             Group = self._makeGroup()
             group = Session.query(Group).all()[0]

mgedmin avatar Feb 17 '12 21:02 mgedmin