The Fix
pip install redis==7.1.0
Based on closed redis/redis-py issue #2462 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -5581,7 +5581,7 @@ def _geosearchgeneric(
)
pieces.extend([b"FROMMEMBER", kwargs["member"]])
- if kwargs["longitude"] and kwargs["latitude"]:
+ if kwargs["longitude"] is not None and kwargs["latitude"] is not None:
pieces.extend([b"FROMLONLAT", kwargs["longitude"], kwargs["latitude"]])
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)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install redis==7.1.0\nWhen NOT to use: This fix is not applicable if the geosearch command is used with non-numeric types for longitude or latitude.\n\n
Why This Fix Works in Production
- Trigger: poetry run python playground/bug/main.py
- Mechanism: Fixes the issue where passing 0.0 longitude or latitude to the geosearch command resulted in an error.
- Why the fix works: Fixes the issue where passing 0.0 longitude or latitude to the geosearch command resulted in an error. (first fixed release: 7.1.0).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Shows up under Python 3.9.15 in real deployments (not just unit tests).
- Surfaces as: poetry run python playground/bug/main.py
Proof / Evidence
- GitHub issue: #2462
- Fix PR: https://github.com/redis/redis-py/pull/2464
- First fixed release: 7.1.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-07
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.36
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“The issue gets fixed if lat and lon are passed as strings. This will work:”
“@shacharPash you mentioned being interested in a lightweight PR... I think this could be a decent entrypoint.”
Failure Signature (Search String)
- poetry run python playground/bug/main.py
Error Message
Stack trace
Error Message
-------------
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: wron
... (truncated) ...
Minimal Reproduction
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)
Environment
- Python: 3.9.15
What Broke
The application raises a ResponseError when executing the geosearch command with invalid arguments.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install redis==7.1.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/redis/redis-py/pull/2464
First fixed release: 7.1.0
Last verified: 2026-02-07. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the geosearch command is used with non-numeric types for longitude or latitude.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 7.1.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.