Hello.

I found out mysterious Redis error.

Environment

  • Windows10
  • python version : 3.6.8
  • python redis module version : 3.3.8

Error

redis.zadd("001_BLACK:01001:001:101", {"{'data':'gaga'}": 20180101})
redis.zadd("001_BLACK:01001:001:101", {"{'data':'haha'}": 20180102})
  File "C:/dev/project/aipscm-bizapi/test.py", line 64, in <module>
    redis.zadd("001_BLACK:01001:001:101", {"{'data':'gaga'}": 20180101})
  File "C:\ProgramData\Miniconda3\envs\aipscm_script\lib\site-packages\redis\client.py", line 2391, in zadd
    return self.execute_command('ZADD', name, *pieces, **options)
  File "C:\ProgramData\Miniconda3\envs\aipscm_script\lib\site-packages\redis\client.py", line 839, in execute_command
    return self.parse_response(conn, command_name, **options)
  File "C:\ProgramData\Miniconda3\envs\aipscm_script\lib\site-packages\redis\client.py", line 853, in parse_response
    response = connection.read_response()
  File "C:\ProgramData\Miniconda3\envs\aipscm_script\lib\site-packages\redis\connection.py", line 717, in read_response
    raise response
redis.exceptions.ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value

however, below command does not show errors

redis.zadd("001BLACK:01001:001:101", {"{'data':'gaga'}": 20180101})
redis.zadd("001BLACK:01001:001:101", {"{'data':'haha'}": 20180102})

redis.zadd("0_01BLACK:01001:001:101", {"{'data':'gaga'}": 20180101})
redis.zadd("0_01BLACK:01001:001:101", {"{'data':'haha'}": 20180102})

Comment From: itamarhaber

Hello @da91love

The error you're getting is not mysterious - it tells you that the key ("001_BLACK:01001:001:101") holds a value of the wrong type for this operation, i.e. not a Sorted Set. You can verify that by connecting to the same database as you code does and checking the key's type (with the TYPE command).

Keep in mind that this issue tracker should be used for reporting bugs or proposing improvements to the Redis server. Questions should be directed to the community: