-
Notifications
You must be signed in to change notification settings - Fork 188
Fix request body serialization issues caused by property tracking logic #3301
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
Merged
Conversation
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
…icrosoftgraph/msgraph-sdk-powershell into delayed_loading_of_body_params
Ndiritu
previously approved these changes
May 8, 2025
Ndiritu
approved these changes
May 9, 2025
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.
Summary
This PR removes the custom property tracking (TrackProperty, IsPropertySet) implementation introduced in the AutoRest-generated model classes to control request body serialization.
Root Cause
The tracker was originally added to support:
Explicit property tracking for selective serialization
Type inferencing improvements in ToJson()
Allowing users to explicitly set null on supported fields
However, this approach introduced significant instability in the cmdlet behavior — especially during first-time use within a PowerShell session. Specifically:
Properties that were set correctly (e.g. passwordProfile.password, displayName) were not serialized if they were not tracked in time
Nested model properties were dropped unless explicitly tracked and materialized before serialization
The timing of TrackProperty() invocation became unreliable due to dynamic type conversion and delayed binding in the PowerShell runtime
As a result, critical properties were inconsistently omitted from request payloads, leading to broken API calls and hard-to-reproduce bugs.
Fix
This change removes the TrackProperty and IsPropertySet directives and restores PowerShell’s default permissive behavior:
All explicitly set properties (including nested model fields) are now included in the serialized request body by default
Behavior is consistent across first-time and repeated cmdlet usage
The JSON output is no longer dependent on reflective timing or session state
Impact
Fixes multiple reported issues (#3286, #3298, #3304, #3307, #3308, #3309) with properties missing in request payloads
Aligns request body serialization with standard PowerShell model handling
No breaking change expected — only improves consistency