MagicStack / MagicStack/asyncpg

Connect with passwordless DSN does not work

Open
#1,286 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.1k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

Basically as the title says: Trying to connect with a DSN that contains no password does not work

DSN in question:

`
@property
def dsn(self) -> str:
return f"postgresql+asyncpg://{self.pguser}@{self.pghost}:{self.pgport}/{self.pgdatabase}"
`

results, when used with

`
def get_db_url() -> str:
config = get_config()
return config.postgres.dsn

engine = create_async_engine(
get_db_url(),
echo=True,
future=True,
)
`

in the error:

`
ERROR: Traceback (most recent call last): File "asyncpg/protocol/coreproto.pyx", line 168, in asyncpg.protocol.protocol.CoreProtocol._process__auth File "asyncpg/protocol/coreproto.pyx", line 577, in asyncpg.protocol.protocol.CoreProtocol._parse_msg_authentication File "asyncpg/protocol/coreproto.pyx", line 672, in asyncpg.protocol.protocol.CoreProtocol._auth_password_message_cleartext AttributeError: 'NoneType' object has no attribute 'encode'
`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the passwordless PostgreSQL DSN shown and the create_async_engine entry point. Trace the password-authentication path around the reported _auth_password_message_cleartext traceback; done means a passwordless connection no longer raises the NoneType encode error, with coverage for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python, sqlalchemy
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.