git-hulk opened a new issue, #633: URL: https://github.com/apache/incubator-kvrocks/issues/633
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/incubator-kvrocks/issues) and found no similar issues. ### Version b1eb17f0228b40244694b308639a8876c90444ba ### Minimal reproduce step According to https://redis.io/docs/reference/protocol-spec/#resp-arrays, empty/null array is allowed in RESP but Kvrocks got the protocol error. ```shell # empty array $ echo '*0\r\n*2\r\n$3\r\nget\r\n$3\r\nkey\r\n'|nc 127.0.0.1 6666 # null array $ echo '*-1\r\n*2\r\n$3\r\nget\r\n$3\r\nkey\r\n'|nc 127.0.0.1 6666 ``` ### What did you expect to see? Kvrocks can parse those protocol correctly and response the right value of the `key` like Redis behavior: ```shell ❯ echo '*0\r\n*2\r\n$3\r\nget\r\n$3\r\nkey\r\n'|nc 127.0.0.1 6379 $-1 ❯ echo '*-1\r\n*2\r\n$3\r\nget\r\n$3\r\nkey\r\n'|nc 127.0.0.1 6379 $-1 ``` ### What did you see instead? ```shell ❯ echo '*0\r\n*2\r\n$3\r\nget\r\n$3\r\nkey\r\n'|nc 127.0.0.1 6666 -Protocol error: expected '$' ❯ echo '*-1\r\n*2\r\n$3\r\nget\r\n$3\r\nkey\r\n'|nc 127.0.0.1 6666 -Protocol error: invalid multibulk length ``` ### Anything Else? For the empty array case, Kvrocks should NOT enter the next state when the multi bulk length is 0 at line:[redis_request.cc#L71](https://github.com/apache/incubator-kvrocks/blob/unstable/src/redis_request.cc#L71) For the null array case, Kvrocks should use `stoll` to parse the number instead of `stoull` since the length maybe negative at line: [redis_request.cc#L62](https://github.com/apache/incubator-kvrocks/blob/unstable/src/redis_request.cc#L62). Also, we need to skip the null array like the empty array case. ### Are you willing to submit a PR? - [ ] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
