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

Wrong number of arguments for 'geosearch' command #2462

Closed
petru-motrescu opened this issue Nov 18, 2022 · 2 comments · Fixed by #2464
Closed

Wrong number of arguments for 'geosearch' command #2462

petru-motrescu opened this issue Nov 18, 2022 · 2 comments · Fixed by #2464
Assignees
Labels
bug Bug

Comments

@petru-motrescu
Copy link

petru-motrescu commented Nov 18, 2022

Version:
redis-py: 4.3.4
Redis: 7.0.5

Platform:
Python 3.9.15 (main, Oct 11 2022, 21:39:54)
[Clang 14.0.0 (clang-1400.0.29.102)] on darwin
MacOS

Description:
Passing 0.0 longitude or latitude to geosearch results in:
redis.exceptions.ResponseError: wrong number of arguments for 'geosearch' command

def main():
    redis = Redis.from_url(url="redis://localhost:6379")
    key = "theindex"
    lon: float = 0.0
    lat: float = 1.0
    redis.geoadd(name=key, values=[lon, lat, "foo"])
    results = redis.geosearch(name=key, longitude=lon, latitude=lat, radius=1, unit="km")
    print(results)

Stack trace:

poetry run python playground/bug/main.py
Traceback (most recent call last):
  File "/Users/petru/PLAY/redis-playground/playground/bug/main.py", line 22, in <module>
    main()
  File "/Users/petru/PLAY/redis-playground/playground/bug/main.py", line 18, in main
    results = redis.geosearch(name=key, longitude=lon, latitude=lat, radius=1, unit="km")
  File "/.../python3.9/site-packages/redis/commands/core.py", line 5474, in geosearch
    return self._geosearchgeneric(
  File "/.../python3.9/site-packages/redis/commands/core.py", line 5605, in _geosearchgeneric
    return self.execute_command(command, *pieces, **kwargs)
  File "/.../python3.9/site-packages/redis/client.py", line 1238, in execute_command
    return conn.retry.call_with_retry(
  File "/.../python3.9/site-packages/redis/retry.py", line 46, in call_with_retry
    return do()
  File "/.../python3.9/site-packages/redis/client.py", line 1239, in <lambda>
    lambda: self._send_command_parse_response(
  File "/.../python3.9/site-packages/redis/client.py", line 1215, in _send_command_parse_response
    return self.parse_response(conn, command_name, **options)
  File "/.../python3.9/site-packages/redis/client.py", line 1254, in parse_response
    response = connection.read_response()
  File "/.../python3.9/site-packages/redis/connection.py", line 839, in read_response
    raise response
redis.exceptions.ResponseError: wrong number of arguments for 'geosearch' command
@petru-motrescu
Copy link
Author

The issue gets fixed if lat and lon are passed as strings. This will work:

def main():
    redis = Redis.from_url(url="redis://localhost:6379")
    key = "theindex"
    lon = "0.0"
    lat = "1.0"
    redis.geoadd(name=key, values=[lon, lat, "foo"])
    results = redis.geosearch(name=key, longitude=lon, latitude=lat, radius=1, unit="km")
    print(results)

@chayim
Copy link
Contributor

chayim commented Nov 29, 2022

@shacharPash you mentioned being interested in a lightweight PR... I think this could be a decent entrypoint.

chayim pushed a commit that referenced this issue Dec 1, 2022
Co-authored-by: Chayim <chayim@users.noreply.github.com>
Fixes #2462
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.

4 participants