-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[PYD-141] PostgresDsn doesn't accept valid socket for host host #3900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
P.S. Valid format of postgres connection string:
References https://www.postgresql.org/docs/current/libpq-connect.html Browsing the code I see that PostgresDsn subclasses AnyUrl, I think it's quite possible to construct a valid Postgres connection string that is not a valid URL. |
I've encountered the same thing a few days ago. |
Ran into this due to google cloud. Seems like #960 was closed Do you think the community would be open to a PR to support a new PostgresDsn -- e.g. GoogleCloudPostgresDsn |
Yup - just ran into this on https://github.com/danizen/fastapi-bakeoff |
My guess would be that this is fixed in v2 she therefore main, PR welcome to add a unit test to check. |
I would have been happy to add a unit test but unfortunately such a DNS still isn't considered valid. >>> PGSettings(dsn="postgresql://derp@/databasename?host=/var/run/postgresql")
dsn
Input should be a valid URL, empty host [type=url_parsing, input_value='postgresql://derp@/datab...ost=/var/run/postgresql', input_type=str] However, what's new is that the following is considered valid in v2 (which is not the case in v1): PGSettings(dsn="postgresql://derp@%2Fvar%2Frun%2Fpostgresql/databasename") |
Thanks for investigating, looks like this needs to be fixed in pydantic-core, I've created pydantic/pydantic-core#378. PR welcome to fix that. |
We’re no longer actively developing Pydantic V1 (although it will continue to receive security fixes for the next year or so), so we’re closing issues solely related to V1. If you really think this shouldn’t be closed, please comment or create a new issue 🚀. |
Uh oh!
There was an error while loading. Please reload this page.
Checks
Bug
It is valid to give a unix socket file as a host when connecting to Postgres (e.g. via sqlalchemy) but PostgresDsn throws a 'URL host invalid' error.
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:PYD-141
The text was updated successfully, but these errors were encountered: