Home > Blockchain >  Error with redis protocol (RESP) during bulk load when data contains UTF-8 characters
Error with redis protocol (RESP) during bulk load when data contains UTF-8 characters

Time:06-30

I have to do simple structured bulk load on my redis database. However there are also some UTF-8 characters and when I'm trying to load in data with them I am getting ERR Protocol error: expected '$', got ' ' . Loading in data without UTF-8 characters works just fine.

Data example of UTF-8 char that is causing the error :

*4\r\n$4\r\nHSET\r\n$6\r\nGrad_Ž\r\n$6\r\nalmada\r\n$1\r\n1\r\n

If I replace Ž with normal character like S for example it loads and causes no errors.

I have tried different commands to run it and I have tried changing bash locale.

Command I am using to run it :

echo -e "$(cat test.txt)" | redis-cli --pipe

Thanks in advance.

CodePudding user response:

In your case:

$6\r\nGrad_Ž\r\n

6 means that there's 6 bytes value, however, Grad_Ž has more than 6 bytes. Because Ž is NOT an ascii character, and takes more than 1 byte.

You need to set the correct string length (in byte) for the value.

  • Related