Fixing _sign_in_state serialization/deserialization#264
Merged
rodrigobr-msft merged 3 commits intomainfrom Dec 1, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request successfully refactors the _SignInState class to use Pydantic's BaseModel for improved data modeling, validation, and serialization. The changes align with the existing pattern used in _FlowState and modernize the codebase by leveraging Pydantic's built-in capabilities.
Key changes:
- Converted
_SignInStatefrom manual initialization to Pydantic field declarations, eliminating boilerplate code - Replaced manual dictionary construction with Pydantic's
model_dump()andmodel_validate()methods for serialization/deserialization - Added comprehensive test coverage for the new serialization mechanism, including file-based round-trip testing
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/oauth/_sign_in_state.py |
Refactored to use Pydantic BaseModel with field annotations, replacing manual __init__ and dict-based serialization with model_dump() and model_validate() |
tests/hosting_core/app/_oauth/test_sign_in_state.py |
Added new test verifying serialization/deserialization correctness, including JSON file round-trip validation |
tests/hosting_core/app/_oauth/_common.py |
Improved test utility by constructing real Activity objects instead of using mock attribute assignment |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cleemullins
approved these changes
Dec 1, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rodrigobr-msft
added a commit
that referenced
this pull request
Dec 1, 2025
* Fixing _sign_in_state (de)serialization * Reformatting --------- Co-authored-by: Chris Mullins <cleemullins@users.noreply.github.com>
rodrigobr-msft
added a commit
that referenced
this pull request
Dec 1, 2025
* Getting package version from file when building packages (#261) * Writing version to file and reading it when building * Fixing issue * Removed unnecessary declaration * Specifying encoding * Adding MANIFEST.in file to include package version files in builds (#263) * Writing version to file and reading it when building * Fixing issue * Removed unnecessary declaration * Specifying encoding * Adding MANIFEST.in files to include VERSION.txt * Fixing _sign_in_state serialization/deserialization (#264) * Fixing _sign_in_state (de)serialization * Reformatting --------- Co-authored-by: Chris Mullins <cleemullins@users.noreply.github.com> --------- Co-authored-by: Chris Mullins <cleemullins@users.noreply.github.com>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request refactors the
_SignInStateclass to use Pydantic for data modeling and validation, simplifying serialization and deserialization logic. It also updates related test utilities and adds a new test to verify the correctness of the new serialization approach.Refactoring and code improvements:
_SignInStateclass in_sign_in_state.pyto inherit frompydantic.BaseModelalongsideStoreItem, removing the manual__init__and leveraging Pydantic's model-based serialization and validation methods (model_dump,model_validate).store_item_to_jsonandfrom_json_to_store_itemmethods in_SignInStateto use Pydantic's serialization/deserialization utilities, streamlining the code and improving maintainability.Testing improvements:
test_sign_in_state_serialization_deserializationintest_sign_in_state.pyto ensure that_SignInStateobjects can be correctly serialized to and deserialized from JSON, including file round-tripping.create_testing_TurnContextutility in_common.pyto construct theActivityobject directly, aligning with the updated data model.