redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a byte, string or number first

12,683

Check this link: redis 3.0 It says that the redis-py no longer accepts NoneType

Share:
12,683
furuneko
Author by

furuneko

Updated on June 23, 2022

Comments

  • furuneko
    furuneko almost 2 years

    I've recently started to use Redis and RQ to run background processes. I built a Dash app which works fine on Heroku and used to work locally as well. Recently, I tried to test the same app locally again and I keep getting the following error - although I'm using exactly the same code hosted on Heroku:

    redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a byte, string or number first.
    

    In my requirements.txt and virtual env on Ubuntu 18.04 I have redis v.3.0.1, rq 0.13.0

    When I run redis-server on my terminal I see that Redis 4.0.9 is used (that's also confusing to me).

    I tried to google for two days looking for a solution with no avail.

    Has anyone an idea of what might have happened and how to solve this error?

    Here is the full relevant traceback:

    File "/home/tom/dashenv/pb101_models/pages/cumulative_culture.py", line 1026, in stop_or_start_update
      job = q.fetch_job(job_id)
    File "/home/tom/dashenv/dash/lib/python3.6/site-packages/rq/queue.py", line 142, in fetch_job
      self.remove(job_id)
    File "/home/tom/dashenv/dash/lib/python3.6/site-packages/rq/queue.py", line 186, in remove
      return self.connection.lrem(self.key, 1, job_id)
    File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/client.py", line 1580, in lrem
      return self.execute_command('LREM', name, count, value)
    File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/client.py", line 754, in execute_command
      connection.send_command(*args)
    File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 619, in send_command
      self.send_packed_command(self.pack_command(*args))
    File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 659, in pack_command
      for arg in imap(self.encoder.encode, args):
    File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 124, in encode
      "byte, string or number first." % typename)
    redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a byte, string or number first.
    

    Thanks in advance for any suggestion/hint.

    All best, Tom