Closed
Description
- asyncpg version: 0.20.1
- PostgreSQL version: 9.6
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: Azure PostgreSQL. It is reproducible with a local install. - Python version: 3.7.7
- Platform: Docker/Debian, locally OSX
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
- If you built asyncpg locally, which version of Cython did you use?: N/A, installed from wheel.
- Can the issue be reproduced under both asyncio and
uvloop?: Yes
Azure managed databases have credentials as follows:
url: instance-name.privatelink.postgres.database.azure.com
database: db-name
username: db-name@instance-name
password: password
Combining that into a DSN, we get something like:
postgres://db-name@instance-name:password@instance-name.privatelink.postgres.database.azure.com:5432/db-name
But the utility to interpret the DSN makes a mistake when trying to interpret a DSN of this shape:
File "/turn-rasa-connector/turn_rasa_connector/turn.py", line 163, in get_postgresql_pool
self._postgresql_pool = await asyncpg.create_pool(self.postgresql_url)
File "/opt/venv/lib/python3.7/site-packages/asyncpg/pool.py", line 398, in _async__init__
await self._initialize()
File "/opt/venv/lib/python3.7/site-packages/asyncpg/pool.py", line 426, in _initialize
await first_ch.connect()
File "/opt/venv/lib/python3.7/site-packages/asyncpg/pool.py", line 125, in connect
self._con = await self._pool._get_new_connection()
File "/opt/venv/lib/python3.7/site-packages/asyncpg/pool.py", line 472, in _get_new_connection
**self._connect_kwargs)
File "/opt/venv/lib/python3.7/site-packages/asyncpg/connection.py", line 1677, in connect
max_cacheable_statement_size=max_cacheable_statement_size)
File "/opt/venv/lib/python3.7/site-packages/asyncpg/connect_utils.py", line 645, in _connect
addrs, params, config = _parse_connect_arguments(timeout=timeout, **kwargs)
File "/opt/venv/lib/python3.7/site-packages/asyncpg/connect_utils.py", line 496, in _parse_connect_arguments
server_settings=server_settings)
File "/opt/venv/lib/python3.7/site-packages/asyncpg/connect_utils.py", line 236, in _parse_connect_dsn_and_args
host, port = _parse_hostlist(dsn_hostspec, port, unquote=True)
File "/opt/venv/lib/python3.7/site-packages/asyncpg/connect_utils.py", line 196, in _parse_hostlist
hostlist_ports.append(int(hostspec_port))
ValueError: invalid literal for int() with base 10: 'password@instance-name.privatelink.postgres.database.azure.com:5432'
It seems like it is taking the first @
symbol when splitting between the instance name and credentials, instead of the last @
symbol.
This also happens locally when creating a user that has an @
symbol in the username.
Metadata
Metadata
Assignees
Labels
No labels