Skip to content
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

pydantic_core.MultiHostUrl and pydantic_core.Url not support password as empty string #1144

Closed
duchuyvp opened this issue Jan 3, 2024 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@duchuyvp
Copy link

duchuyvp commented Jan 3, 2024

When I create a pydantic_core.Url with password as empty string as follow (similar with MultiHostUrl):

uri = pydantic_core.Url.build(
    scheme="clickhouse",
    username="user",
    password="",
    host="localhost",
    port=8123,
    path="ch_db",
)

print(uri.__str__())

I expected clickhouse://user:@localhost:8123/ch_db (password as empty string)

But I got clickhouse://user@localhost:8123/ch_db. I think what I got seems good only when password is None.

I faced this problem when try to connect to Clickhouse with clickhouse_connect

clickhouse_connect.get_client(dsn=uri.__str__())

It raised Wrong password error. Even I have a solution is use dns="clickhouse://user:@localhost:8123/ch_db" but I think it's not good practice.

Is pydantic_core support create Url with empty password

@davidhewitt
Copy link
Contributor

Looking at the underlying Rust library's issue on this topic: servo/rust-url#793

The conclusion seems to be that the URL standard makes no distinction between user:@ and user@. The password should be treated as the empty string either way.

https://url.spec.whatwg.org/#url-serializing

So I believe that this is correct, and it is the clickhouse parser which is not compliant here.

@sydney-runkle
Copy link
Member

Marking as resolved, given the analysis above. Thanks @davidhewitt !

@sydney-runkle sydney-runkle closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2024
@sydney-runkle sydney-runkle added question Further information is requested and removed unconfirmed labels Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants