.Net: Fixed record mapping in Azure CosmosDB MongoDB connector #8823
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Closes: #8694
Previous version of record mapping relied on
AzureCosmosDBMongoDBNamingConvention
class which was applied globally. This approach introduced some issues in unit tests in CI pipeline, like here: https://github.com/microsoft/semantic-kernel/actions/runs/10828226455/job/30043117037?pr=8693, although it's not possible to reproduce it locally. It looks like global naming policy registration sometimes is delayed or ignored, which causes tests to fail occasionally.To avoid this transient issue, the logic of record mapping was updated to rely only on record property name or
BsonElement
name and use native BSON {de}serialization logic without global naming policies. Additional logic was added to handle key mapping, since key in MongoDB has a constant name_id
, so it should be handled differently comparing to other fields.Description
Contribution Checklist