Skip to content

Error when calling .exec() on empty pipeline #69

Description

@fungs

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

  1. Init empty async pipeline.
  2. Call exec() → exception.
  3. Try len()/bool() → fails.

Request

  1. Make empty exec() return [] safely (skip HTTP if empty).
  2. Implement len returning queued command count, bool as len(self) > 0.
  3. 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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions