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

MongoDsn injects port value on mongodb+srv:// URIs #6774

Closed
1 task done
heissonwillen opened this issue Jul 20, 2023 · 3 comments · Fixed by #6827
Closed
1 task done

MongoDsn injects port value on mongodb+srv:// URIs #6774

heissonwillen opened this issue Jul 20, 2023 · 3 comments · Fixed by #6827
Assignees
Labels
bug V2 Bug related to Pydantic V2 unconfirmed Bug not yet confirmed as valid/applicable

Comments

@heissonwillen
Copy link

heissonwillen commented Jul 20, 2023

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

MongoDB URIs using the format mongodb+srv:// shouldn't contain a port number.

The default MongoDsn type automatically injects a port value. I'm working that around using my own MongoDsn type:

MongoDsn = Annotated[
    MultiHostUrl,
    UrlConstraints(
        allowed_schemes=["mongodb", "mongodb+srv"],
    ),
]

It would be great to have Pydantic not injecting a value that will cause a database connection issue.

Example Code

No response

Python, Pydantic & OS Version

pydantic version: 2.0.3
        pydantic-core version: 2.3.0 release build profile
                 install path: /Users/my-user/Projects/my-project/venv/lib/python3.11/site-packages/pydantic
               python version: 3.11.3 (main, Apr  7 2023, 20:13:31) [Clang 14.0.0 (clang-1400.0.29.202)]
                     platform: macOS-13.2.1-arm64-arm-64bit
     optional deps. installed: ['typing-extensions']

Selected Assignee: @dmontagu

@heissonwillen heissonwillen added bug V2 Bug related to Pydantic V2 unconfirmed Bug not yet confirmed as valid/applicable labels Jul 20, 2023
@heissonwillen heissonwillen changed the title MongoDsn injects port value on on mongodb+srv:// URIs MongoDsn injects port value on mongodb+srv:// URIs Jul 20, 2023
@dmontagu
Copy link
Contributor

dmontagu commented Jul 24, 2023

Could you provide a more complete code example showing what is happening that you don't like, and what you want the behavior to be? I'm not familiar with the type involved, it would just help to see how you are running into the problem.

@dmontagu
Copy link
Contributor

@heissonwillen does #6774 fix it for you?

@heissonwillen
Copy link
Author

Yep! Thanks for taking a look! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V2 Bug related to Pydantic V2 unconfirmed Bug not yet confirmed as valid/applicable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants