Describe the bug
redis-cli --scan does not work correctly with binary keys: - binary data is not returned to terminal - scan operation yields no matches when MATCH pattern contains binary data
To reproduce Set binary key
127.0.0.1:6379> set "cp\x00\x01\x15\xc5\x00\x01\x15\xc5b64068ae-3d87-4d9a-b928-847adf4e22bf" "\x00\x02"
OK
command line scan with binary pattern yields no results
~ $ redis-cli --scan --pattern "cp\x00*"
~ $
command line scan without binary pattern (does not return binary part of the key)
~ $ redis-cli --scan --pattern "cp*"
cp
~ $
Expected behavior
Expected to set key and retrieve in command line scan
127.0.0.1:6379> set "cp\x00\x01\x15\xc5\x00\x01\x15\xc5b64068ae-3d87-4d9a-b928-847adf4e22bf" "\x00\x02"
OK
command line scan by with binary pattern
~ $ redis-cli --scan --pattern "cp\x00*"
cp\x00\x01\x15\xc5\x00\x01\x15\xc5b64068ae-3d87-4d9a-b928-847adf4e22bf
~ $
command line scan without binary pattern
~ $ redis-cli --scan --pattern "cp*"
cp\x00\x01\x15\xc5\x00\x01\x15\xc5b64068ae-3d87-4d9a-b928-847adf4e22bf
~ $
Additional information running scan from the client works as expected:
127.0.0.1:6379> scan 0 match cp* count 10000
1) "0"
2) 1) "cp\x00\x01\x15\xc5\x00\x01\x15\xc5b64068ae-3d87-4d9a-b928-847adf4e22bf"