Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Mar 24, 2024

Conversation

lmaas
Copy link
Contributor

@lmaas lmaas commented Mar 23, 2024

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.

@badrishc badrishc merged commit d33fc02 into main Mar 24, 2024
9 checks passed
@badrishc badrishc deleted the lumaas/object-errorhandling branch March 24, 2024 17:37
This was referenced Mar 25, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2024
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