dice icon indicating copy to clipboard operation
dice copied to clipboard

Inconsistent `JSON.OBJLEN`: Add error-message for when querying non-existent key

Open paulwalrath opened this issue 1 year ago • 3 comments

Steps to reproduce

When I was writing the documentation for the JSON.OBJLEN command, I made it to be similar to the JSON.OBJKEYS command, which is very similar.

But while investigating, I discovered an inconsistency in the JSON.OBJLEN command; it doesn't return an error message when you use it to query a non-existent key.

To reproduce, try running the JSON.OBJLEN command on a key that you know does not exist in the datastore. You will get a blank response. But it should return an error message saying the key does not exist.

Expected output

If you use the command to query a key that doesn't exist, it should give an error:

dicedb> JSON.OBJLEN nonexistent_key $
(error) ERR could not perform this operation on a key that doesn't exist

Observed output

Presently, it does not return an error:

dicedb> JSON.OBJLEN nonexistent_key $
Error: redis: nil

Expectations for resolution

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

  1. the implementation for that command is in the evalJSONOBJLEN() function in internal/eval/store_eval.go. Change the EvalResponse object so it returns the diceerrors.ErrKeyDoesNotExist error, instead of nil.
  2. modify test cases in integration_tests for this change.

paulwalrath avatar Dec 03 '24 00:12 paulwalrath

Hi @paulwalrat, are you still working on this ? would love to start with this

akhilk2802 avatar Dec 15 '24 18:12 akhilk2802

Hi @paulwalrat, are you still working on this ? would love to start with this

Hi there. Sorry, there's nothing to do. The work is already done (see PR 1354) and is waiting to be merged.

paulwalrath avatar Dec 15 '24 18:12 paulwalrath

Got it

akhilk2802 avatar Dec 15 '24 19:12 akhilk2802

Closing, merged as part of https://github.com/DiceDB/dice/pull/1354.

lucifercr07 avatar Dec 17 '24 04:12 lucifercr07