Skip to content

PostgresDsn fails for multiple hosts #3337

Closed
@StupidHobbit

Description

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

pydantic version: 1.8.2
pydantic compiled: False
install path: /home/stupidhobbit/arc/arcadia/contrib/python/pydantic/pydantic
python version: 3.9.7 (default, Oct 13 2021, 18:49:29)  [Clang 12.0.1 ]
platform: Linux-5.4.0-66-generic-x86_64-with-glibc2.27
optional deps. installed: ['typing-extensions']
from pydantic import BaseSettings, PostgresDsn


class PGSettings(BaseSettings):
    dsn: PostgresDsn = 'postgres://user:pass@host1.db.net,host2.db.net:6432/db'

This code gives you this error:

pydantic.error_wrappers.ValidationError: 1 validation error for PGSettings
dsn
  URL host invalid (type=value_error.url.host)

But this is a valid dsn for postgres and it works just fine with psycopg2

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions