Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

[#6582, #6584] Incorrect serialization of state when using Blob or CosmosDB storage in v4.19.x - #6585

Merged
tracyboehrer (tracyboehrer) merged 2 commits into
mainfrom
southworks/fix/serialization-binder
Feb 13, 2023
Merged

tracyboehrer (tracyboehrer) merged 2 commits into
mainfrom
southworks/fix/serialization-binder

Conversation

@sw-joelmut

Copy link
Copy Markdown
Collaborator

Fixes #6582
Fixes #6584

Description

This PR refactors the AllowedTypesSerializationBinder class to allow custom types to be loaded dynamically, this includes types from BotBuilder and the project who is using it (e.g. a bot sample).
Also, the process verifies the serialized and deserialized types are allowed or valid, otherwise it will fail with the following message sample:
image

Specific Changes

  • Adds the LoadTypes method to dynamically load types from external projects (e.g. a bot sample), internal libraries (BotBuilder, with its nested related types).
  • Adds Verify method, that validates after serializing and deserializing an object, it has all valid or allowed types, otherwise it will fail.
  • Removed CleanupTypes method, since all types are now saved equally into the Storage, and validated when read or write.
  • Removed, updated and added new unit tests to validate the new implementation.

Testing

The following image shows the changes working with Blobs Storage and CosmosDB.
image

@sw-joelmut
Joel Mut (sw-joelmut) requested a review from a team as a code owner February 3, 2023 19:59
@sw-joelmut Joel Mut (sw-joelmut) added the Automation: No parity PR does not need to be applied to other languages. label Feb 3, 2023
@coveralls

Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 339272

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.004%) to 73.354%

Files with Coverage Reduction New Missed Lines %
/libraries/Microsoft.Bot.Builder/AllowedTypesSerializationBinder.cs 4 95.35%
Totals Coverage Status
Change from base Build 337253: -0.004%
Covered Lines: 23937
Relevant Lines: 32632

💛 - Coveralls

@BruceHaley

Copy link
Copy Markdown
Contributor

✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.dll
✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.Azure.dll

@tracyboehrer
tracyboehrer (tracyboehrer) deleted the southworks/fix/serialization-binder branch February 13, 2023 14:17
tracyboehrer (tracyboehrer) pushed a commit that referenced this pull request Feb 13, 2023
…smosDB storage in v4.19.x (#6585)

* Refactor AllowedTypesSerializationBinder to dynamically load types

* Update AllowedTypesSerializationBinder tests
tracyboehrer (tracyboehrer) pushed a commit that referenced this pull request Feb 21, 2023
…ob or CosmosDB storage in v4.19.x (#6585)"

This reverts commit e15b38d.
tracyboehrer (tracyboehrer) added a commit that referenced this pull request Feb 23, 2023
* Revert "[#6582, #6584] Incorrect serialization of state when using Blob or CosmosDB storage in v4.19.x (#6585)"

This reverts commit e15b38d.

* Revert "Fix CodeQL SM02211 alert - SerializationBinder (#6549)"

This reverts commit 1ee5f6a.

* Skip TypeNameHandling CodeQL issue from Azure and Blobs storage (#6592)

---------

Co-authored-by: Tracy Boehrer <trboehre@microsoft.com>
Co-authored-by: Joel Mut <62260472+sw-joelmut@users.noreply.github.com>
This was referenced May 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Automation: No parity PR does not need to be applied to other languages.

Projects

None yet

4 participants