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

Got "script tried accessing undeclared key" when key actually exists #3066

Closed
howz97 opened this issue May 20, 2024 · 3 comments
Closed

Got "script tried accessing undeclared key" when key actually exists #3066

howz97 opened this issue May 20, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@howz97
Copy link

howz97 commented May 20, 2024

Describe the bug
Got "script tried accessing undeclared key" when key actually exists

To Reproduce
install drongonfly

docker run --network=host --ulimit memlock=-1 docker.dragonflydb.io/dragonflydb/dragonfly

execute

127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379> eval "redis.call('GET', 'foo')" 0
(error) ERR Error running script (call to 77563f88f961d5772ea29fbc4a18558997365e67): @user_script:2: script tried accessing undeclared key

Expected behavior
eval should succeed

Environment (please complete the following information):

  • OS: [ubuntu 20.04]

  • Kernel: Linux ip-172-31-40-58 5.15.0-1058-aws #64~20.04.1-Ubuntu SMP Tue Apr 9 11:11:55 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux

  • Containerized?: Docker

  • Dragonfly Version: [e.g. 0.3.0]

Reproducible Code Snippet

# Minimal code snippet to reproduce this bug

Additional context
Add any other context about the problem here.

@howz97 howz97 added the bug Something isn't working label May 20, 2024
@dranikpg
Copy link
Contributor

It doesn't matter if the key exists or not, it needs to be added to the EVAL command or specific script options should be used #272

@howz97
Copy link
Author

howz97 commented May 21, 2024

I tried append the key to EVAL, while it return (nil) . Is this a bug? @dranikpg

127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379> eval "redis.call('GET', KEYS[1])" 1 foo
(nil)
127.0.0.1:6379> 

@romange
Copy link
Collaborator

romange commented May 21, 2024

@howz97 you should write : eval "return redis.call('GET', KEYS[1])" 1 foo
note the "return"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants