-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Comments
markwallace-microsoft
added
python
Pull requests for the Python Semantic Kernel
triage
labels
Dec 22, 2024
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
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. |
@moonbox3 / @eavanvalkenburg can you provide guidance on this? |
The PR for this is already good to go, I'll manage |
github-merge-queue bot
pushed a commit
that referenced
this issue
Jan 5, 2025
### Motivation and Context fix #10026 ### Description This PR removes the alias as pydantic requires the usage of the alias when initializing the class not the original name which prevents this code from working. ```py cosmosdb_settings = AzureCosmosDBSettings.create( env_file_path=env_file_path, connection_string=cosmos_connstr, ) ``` ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.semantic-kernel/python/semantic_kernel/connectors/memory/azure_cosmosdb/azure_cosmos_db_memory_store.py
Lines 97 to 100 in 926a590
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:
Expected behavior
For it to instantiate cosmosdb_settings with connection_string that i passed
Platform
The text was updated successfully, but these errors were encountered: