Skip to content

Fix parsing for object store commands with wrong number of arguments - #103

Merged
Badrish Chandramouli (badrishc) merged 5 commits into
mainfrom
lumaas/object-errorhandling
Mar 24, 2024
Merged

Fix parsing for object store commands with wrong number of arguments#103
Badrish Chandramouli (badrishc) merged 5 commits into
mainfrom
lumaas/object-errorhandling

Conversation

@lmaas

Copy link
Copy Markdown
Contributor

This PR addresses a critical bug related to object store commands, where command invocations with incorrect numbers of arguments can corrupt the command stream by prematurely exiting the parsing loop without fully consuming the RESP command.

Bug Description

Steps to Reproduce

redis> HSET x y "Hello"
(integer) 1
redis> HLEN x y # <- Incorrect input
(integer) 0
redis> HGET x y
(error) ERR unknown command

Expected Result

redis> HGET x y
"Hello"

Actual Result

Due to the parsing stream assuming that “y” is the next command name, the subsequent command is incorrectly flagged as unknown.

Changes

To fix this issue, the following changes have been made:

  • Replaced WriteErrorTokenNumberInCommand() with a new function called AbortWithWrongNumberOfArguments(). This new function ensures that any remaining arguments left in the input stream are properly drained before returning the error related to incorrect #arguments.
  • Corrected the maximum number of arguments for the following commands: HLEN, HEXISTS, HINCRBY, HINCRBYFLOAT, SCARD, and ZCARD.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants