Skip to content

Conversation

@ms-henglu
Copy link
Collaborator

This commit fixes issue #59 where PATCH operations fail for polymorphic Microsoft Graph resources (like namedLocations) that require @odata.type discriminator fields to always be present.

Changes:

  • Modified DiffObject() in internal/utils/json.go to always include @OData.* fields when there are other changes, even if those fields haven't changed themselves
  • Added comprehensive test cases for various @OData.* field scenarios
  • Added acceptance test TestAcc_ResourceNamedLocationWithODataType to verify the fix works with real Microsoft Graph API endpoints

The fix ensures that:

  1. @odata.type and other @OData.* fields are preserved in PATCH requests
  2. The optimization from PR send only changed fields on update #47 (minimal PATCH payloads) is maintained
  3. Issue deviceManagement/configurationPolicies - update fails #36 (navigation property errors) is not reintroduced

Fixes: #59

This commit fixes issue microsoft#59 where PATCH operations fail for polymorphic
Microsoft Graph resources (like namedLocations) that require @odata.type
discriminator fields to always be present.

Changes:
- Modified DiffObject() in internal/utils/json.go to always include
  @OData.* fields when there are other changes, even if those fields
  haven't changed themselves
- Added comprehensive test cases for various @OData.* field scenarios
- Added acceptance test TestAcc_ResourceNamedLocationWithODataType to
  verify the fix works with real Microsoft Graph API endpoints

The fix ensures that:
1. @odata.type and other @OData.* fields are preserved in PATCH requests
2. The optimization from PR microsoft#47 (minimal PATCH payloads) is maintained
3. Issue microsoft#36 (navigation property errors) is not reintroduced

Fixes: microsoft#59
@ms-henglu ms-henglu merged commit c1679da into microsoft:main Dec 12, 2025
10 checks passed
@ms-henglu ms-henglu deleted the fix-issue-59-odata-type-patch branch December 12, 2025 05:13
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.

Patch operation fails due to missing mandatory property

1 participant