AsyncPipeline exec() on empty pipeline raises exception; missing len()/bool compatibility
In upstash-redis, creating an empty pipeline and calling await pipeline.exec() results in an exception from the underlying HTTP library. Additionally, len(pipeline) and bool(pipeline) checks fail, preventing portable pre-exec validation.
Expected Behavior (redis-py/aioredis):
- Empty pipeline.exec() returns [] without network call.
- len(pipeline) == 0 and if pipeline: work via len/bool.
Reproduction
- Init empty async pipeline.
- Call exec() → exception.
- Try len()/bool() → fails.
Request
- Make empty exec() return [] safely (skip HTTP if empty).
- Implement len returning queued command count, bool as len(self) > 0.
- Match redis-py API for drop-in compatibility in serverless apps.
Versions
- upstash-redis: 1.6.0 (latest from PyPI)
- Python: 3.13.3
- Upstash Redis (cloud)
Error
values = await pipeline.exec()
^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.13/site-packages/upstash_redis/asyncio/client.py", line 204, in exec
res: List[RESTResultT] = await self._http.execute( # type: ignore[assignment]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
)
^
File ".venv/lib/python3.13/site-packages/upstash_redis/http.py", line 164, in execute
format_response(sub_response, self._encoding)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.13/site-packages/upstash_redis/http.py", line 191, in format_response
if response.get("error"):
^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'get'
AsyncPipeline exec() on empty pipeline raises exception; missing len()/bool compatibility
In upstash-redis, creating an empty pipeline and calling await pipeline.exec() results in an exception from the underlying HTTP library. Additionally, len(pipeline) and bool(pipeline) checks fail, preventing portable pre-exec validation.
Expected Behavior (redis-py/aioredis):
Reproduction
Request
Versions
Error