Fix async listener for UNIX domain socket PostgreSQL connections#20744
Merged
Fix async listener for UNIX domain socket PostgreSQL connections#20744
Conversation
When using a UNIX domain socket connection URL like: postgresql+asyncpg:///prefect?host=/tmp/.SOSHUB&port=25432 SQLAlchemy's make_url() places host and port in query parameters rather than the standard URL authority section. The pg notify connection builder now falls back to query params when the standard URL attributes are None, allowing UNIX socket connections to work. Closes #20742 Co-Authored-By: Nate Nowack <nate@prefect.io>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
chrisguidry
approved these changes
Feb 18, 2026
zzstoatzz
approved these changes
Feb 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the PostgreSQL async LISTEN/NOTIFY connection when using UNIX domain socket connection URLs (e.g.
postgresql+asyncpg:///prefect?host=/tmp/.SOSHUB&port=25432).SQLAlchemy's
make_url()placeshostandportin the query parameters dict for these URLs rather than the standard.host/.portattributes. The existing code only checked the URL authority attributes, so both wereNonefor socket-style URLs, causing the listener connection to fail.The fix falls back to query params when the standard URL attributes are not set.
Review checklist for humans
int(port)cast is safe for both paths:asyncpg_dsn.port(alreadyint) andquery.get("port")(returnsstr). Theif port:guard preventsint(None).query.get("host")could return a tuple for repeated keys in SQLAlchemy'simmutabledict— unlikely but possible edge case.sslmode) need similar treatment for socket connections.Closes #20742
Checklist
<link to issue>"mint.json.Link to Devin run
https://app.devin.ai/sessions/2a11bbb3200e4b979560213735485e55
Requested by: @zzstoatzz