Minimal, self-contained reproducer for the asyncpg 0.31.0 bug where a
server-side cursor over a result containing an unknown type (an enum) fails with
ProtocolViolationError when statement_cache_size=0.
repro.py— the reproducer (pure asyncpg).Dockerfile—postgres:16-alpinewith the repro's credentials baked in.docker-compose.yaml— runs the database, isolated from other local infra (port5433, containerasyncpg-postgres, volumeasyncpg_pgdata).
- Docker (with
docker compose). - Python 3.x.
Start the database:
docker compose up -dWait until it reports healthy:
docker compose psCreate a virtualenv and install the affected asyncpg version:
python3 -m venv .venv
.venv/bin/pip install 'asyncpg==0.31.0'.venv/bin/python repro.pyprepared name = ''
asyncpg.exceptions.ProtocolViolationError: bind message supplies 2 parameters, but prepared statement "" requires 1
The prepared name = '' line confirms the unnamed-statement precondition, and
the ProtocolViolationError is the regression. If the bug were fixed, the
script would instead stream two rows and print them.
The database listens on 127.0.0.1:5433 with:
| user | asyncpg |
| password | asyncpg_pw |
| database | asyncpg_db |
These are set in docker-compose.yaml / Dockerfile and mirrored in repro.py.
docker compose down # stop and remove the container
docker compose down -v # also delete the asyncpg_pgdata volume