5

I set up a changefeed in Python using the following code:

feed = r.table("table").changes().run(db)

for change in feed:
    print(change)

This crashes on the first update with a UnicodeDecodeError. It turns out RethinkDB appended the sequence \x10\x00\x00\x00\x00\x00\x00\x00\x94\x00\x00\x00 to the end of the returned JSON which crashed the parser. Any other requests to the database work fine.

Where do these characters come from? What can I do about this other than modifying the driver to strip out the extra characters?

Edit: This is an example of a reply, taken from line 73 in net.py (json_str.decode):

{"new_val":{<newly inserted stuff>},"old_val":null}],"n":[1]}\x10\x00\x00\x00\x00\x00\x00\x00\x94\x00\x00\x00
niwax
  • 187
  • 5
  • Does it returns those characters only when working with a particular source? If it is source specific, you may need to wrap your string with .encode('utf8').strip() – Daniel Scott Jan 06 '19 at 01:03
  • Are those bytes/escapes “in” the JSON itself, or literal bytes outside the end of the JSON? – user2864740 Jan 06 '19 at 01:04
  • This is outside of the JSON. I'll add an example into the question shortly. – niwax Jan 06 '19 at 01:14

0 Answers0