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

Python: Bug: Azure MongoDB Connector Assigning Pydantic Fields not by alias #10026

Open
john0isaac opened this issue Dec 22, 2024 · 1 comment · May be fixed by #10027
Open

Python: Bug: Azure MongoDB Connector Assigning Pydantic Fields not by alias #10026

john0isaac opened this issue Dec 22, 2024 · 1 comment · May be fixed by #10027
Labels
bug Something isn't working python Pull requests for the Python Semantic Kernel triage

Comments

@john0isaac
Copy link
Contributor

Describe the bug
When you try to create a new database connection to mongo db you use the class AzureCosmosDBSettings which attempts to parse the env file or the passed arguments.

cosmosdb_settings = AzureCosmosDBSettings.create(
env_file_path=env_file_path,
connection_string=cosmos_connstr,
)

The issue is that the class defines the connection_string with an alias which prevents parsing it correctly as pydantic doesn't allow using both the alias and the attribute name.

See the issue on stackoverflow:
https://stackoverflow.com/questions/69433904/assigning-pydantic-fields-not-by-alias

To Reproduce
Steps to reproduce the behavior:

  1. Try to use this AzureCosmosDBMemoryStore.create() and pass the cosmos_connstr attribute

Expected behavior
For it to instantiate cosmosdb_settings with connection_string that i passed

Platform

  • OS: Mac
  • IDE: Visual Studio
  • Language: Python
  • Source: python-1.17.1
@john0isaac john0isaac added the bug Something isn't working label Dec 22, 2024
@markwallace-microsoft markwallace-microsoft added python Pull requests for the Python Semantic Kernel triage labels Dec 22, 2024
@github-actions github-actions bot changed the title Bug: Azure MongoDB Connector Assigning Pydantic Fields not by alias Python: Bug: Azure MongoDB Connector Assigning Pydantic Fields not by alias Dec 22, 2024
@john0isaac john0isaac linked a pull request Dec 22, 2024 that will close this issue
4 tasks
@john0isaac
Copy link
Contributor Author

There is another solution which is to use populate_by_name in the pydantic class config but I think that not using the alias as better as it conforms with the other setting classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Pull requests for the Python Semantic Kernel triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants