dice icon indicating copy to clipboard operation
dice copied to clipboard

Inconsistent `JSON.ARRLEN`: Mismatching DiceCLI output when compared with RedisCLI output

Open surya0180 opened this issue 1 year ago • 6 comments

Steps to reproduce

I was going through JSON.ARRLEN command and compared the outputs in both redis-cli and dice-cli. Almost all usecases are not giving the expected outputs. I am sharing some screenshots for your reference.

Total 4 mismatches found.

Here are the keys with 2 different JSONs

  • JSON with object in root image

  • JSON with array in root image

Mismatch 1

  • Redis image
  • Dice image

Mismatch 2

  • Redis image
  • Dice image

Mismatch 3

  • Redis image
  • Dice image

Mismatch 4

  • Redis image
  • Dice image

Expected output

The expected output when the above set of commands (maybe when run on Redis)

Expectations for resolution

This issue will be considered resolved when the following things are done

  1. changes in the dice code to meet the expected behavior
  2. addition of relevant test case to ensure we catch the regression

You can find the tests under the integration_tests directory of the dice repository and the steps to run are in the README file. Refer to the following links to set up DiceDB and Redis 7.2.5 locally

surya0180 avatar Oct 06 '24 02:10 surya0180

@lucifercr07 @JyotinderSingh I would like to work on this issue myself

surya0180 avatar Oct 06 '24 02:10 surya0180

@lucifercr07 @JyotinderSingh I would like to work on this issue myself

Assigned

JyotinderSingh avatar Oct 06 '24 02:10 JyotinderSingh

Hi @JyotinderSingh @arpitbbhayani, @lucifercr07.

The current implementation of JSON.ARRLEN is limited to handling straightforward JSONPaths, such as $.key1.key2.... Given that we are directly replicating this command from Redis, it is essential to ensure that its functionality aligns completely with that of Redis. However, the existing implementation lacks coverage for numerous use cases.

To address this, I will compile a comprehensive list of these use cases and work on enhancing JSON.ARRLEN accordingly. Additionally, I will develop test cases to validate the new implementations.

surya0180 avatar Oct 07 '24 03:10 surya0180

Hi @JyotinderSingh @arpitbbhayani, @lucifercr07.

The current implementation of JSON.ARRLEN is limited to handling straightforward JSONPaths, such as $.key1.key2.... Given that we are directly replicating this command from Redis, it is essential to ensure that its functionality aligns completely with that of Redis. However, the existing implementation lacks coverage for numerous use cases.

To address this, I will compile a comprehensive list of these use cases and work on enhancing JSON.ARRLEN accordingly. Additionally, I will develop test cases to validate the new implementations.

We have a list of inconsistencies already that @psrvere had prepared a while back.

https://github.com/DiceDB/dice/issues/493#issuecomment-2350824277

I'll actually create a new issue for this so we have a proper thread to talk about it.

JyotinderSingh avatar Oct 07 '24 05:10 JyotinderSingh

@JyotinderSingh. Ok, for now I will fix the issues in the basic implementation of JSON.ARRLEN and send a PR for this issue. We can then have a new issue for solving inconsistencies related to JSONPaths when compared with redis. Will this work?

surya0180 avatar Oct 07 '24 06:10 surya0180

@JyotinderSingh. Ok, for now I will fix the issues in the basic implementation of JSON.ARRLEN and send a PR for this issue. We can then have a new issue for solving inconsistencies related to JSONPaths when compared with redis. Will this work?

Sounds good!

JyotinderSingh avatar Oct 07 '24 06:10 JyotinderSingh

#997 PR is made for this issue

surya0180 avatar Oct 07 '24 15:10 surya0180