Skip to content

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
merged 27 commits into from
May 9, 2025

Conversation

timayabi2020
Copy link
Contributor

@timayabi2020 timayabi2020 commented Apr 29, 2025

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

@timayabi2020 timayabi2020 changed the title Added implementation for late bound properties Fix request body serialization issues caused by property tracking logic May 8, 2025
@timayabi2020 timayabi2020 marked this pull request as ready for review May 8, 2025 07:59
@timayabi2020 timayabi2020 requested a review from a team as a code owner May 8, 2025 07:59
Ndiritu
Ndiritu previously approved these changes May 8, 2025
@timayabi2020 timayabi2020 merged commit 0e14366 into dev May 9, 2025
7 checks passed
@timayabi2020 timayabi2020 deleted the delayed_loading_of_body_params branch May 9, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants