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

Geo search functions don't work with execute_command #2609

Closed
gnsiva opened this issue Mar 12, 2023 · 0 comments · Fixed by #2628
Closed

Geo search functions don't work with execute_command #2609

gnsiva opened this issue Mar 12, 2023 · 0 comments · Fixed by #2628
Assignees
Labels
bug Bug

Comments

@gnsiva
Copy link

gnsiva commented Mar 12, 2023

Version: What redis-py and what redis version is the issue happening on?

  • redis-py==4.5.1
  • redis docker image redis:5.0.6

Platform: What platform / version? (For example Python 3.5.1 on Windows 7 / Ubuntu 15.10 / Azure)
Linux, python:3.8-slim-bullseye container.

Description: Description of your issue, stack traces from errors and code that reproduces the issue

Below is a minimal example that shows the issue

import redis
c = redis.Redis(host="redis", single_connection_client=True)
c.geoadd(name="my-key", values=[1, 2, "data"])

# works fine
x = c.georadius("my-key", 1, 2, 400, unit="m", withcoord=True)
print(x)

# fails
y = c.execute_command("GEORADIUS", 'my-key', 1, 2, 400, "m")
print(y)

The stack trace printed is:

Traceback (most recent call last):
  File "/opt/.pycharm_helpers/pydev/pydevconsole.py", line 364, in runcode
    coro = func()
  File "<input>", line 1, in <module>
  File "/opt/.pycharm_helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "/opt/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/opt/project/apps/park-out-events/api/parkoutevents/redis_check.py", line 48, in <module>
    y = c.execute_command("GEORADIUS", 'poe-2023-03-11T23:38', 1, 2, 400, "m")
  File "/usr/local/lib/python3.8/site-packages/redis/client.py", line 1238, in execute_command
    return conn.retry.call_with_retry(
  File "/usr/local/lib/python3.8/site-packages/redis/retry.py", line 46, in call_with_retry
    return do()
  File "/usr/local/lib/python3.8/site-packages/redis/client.py", line 1239, in <lambda>
    lambda: self._send_command_parse_response(
  File "/usr/local/lib/python3.8/site-packages/redis/client.py", line 1215, in _send_command_parse_response
    return self.parse_response(conn, command_name, **options)
  File "/usr/local/lib/python3.8/site-packages/redis/client.py", line 1260, in parse_response
    return self.response_callbacks[command_name](response, **options)
  File "/usr/local/lib/python3.8/site-packages/redis/client.py", line 518, in parse_geosearch_generic
    if options["store"] or options["store_dist"]:
KeyError: 'store'

It looks like parse_geosearch_generic expects store and store_dist to be boolean args instead of flags in the CLI commands, like they are in the Python interface.
This also happens for withdist, withcoord, and withhash as the function expects them to be present in **options.

Digging a bit further, even if the call is made with these flags, they aren't passed through and available in the options argument for parse_geosearch_generic, e.g.

r.execute_command("GEORADIUS", "barcelona", 2.187, 41.406, 1000, "m", "WITHDIST")
@gnsiva gnsiva changed the title Geosearch functions don't work with execute_command Geo search functions don't work with execute_command Mar 12, 2023
@dvora-h dvora-h added the bug Bug label Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants