Skip to content

Update/New-MgGroup Overwriting Intended BodyParameter with camelCase keys (schemaExtension Issue) #1327

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

Closed
MrCaedes opened this issue Jun 19, 2022 · 3 comments

Comments

@MrCaedes
Copy link

MrCaedes commented Jun 19, 2022

This was something that's been driving me around in circles the past hour, until I noticed the discrepancy whilst comparing the Graph Explorer behaviour v the MSGraph cmdlets in debug.

When attempting to update (or create) a group with a schemaExtension, such as below;

$Data = @{
    "example_Metadata" = @{
        "Environment" = "DEV";
        "Role" = "MyTest";
        "GroupOwner" = "JohnDoe"
    } 
}
Update-MgGroup -GroupId ee499fb5-2107-4bcd-b488-945b48d71a74 -BodyParameter $Data

The cmdlet reformats the keys (as passed in the BodyParameter) into camelCase, leading to the data held within being updated to "Null" as opposed to the intended value - as it doesn't match the keys as-is within the schema that has been created.

HTTP Method:
PATCH

Absolute Uri:
https://graph.microsoft.com/v1.0/groups/ee499fb5-2107-4bcd-b488-945b48d71a74

Headers:
SdkVersion                    : graph-powershell/1.9.6,Graph-dotnet-1.25.1
FeatureFlag                   : 00000047
Cache-Control                 : no-store, no-cache
User-Agent                    : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.19044; en-GB),PowerShell/2022.5.1,Update-MgGroup_Update1
Accept-Encoding               : gzip

Body:
{
  "example_Metadata": {
    "groupOwner": "JohnDoe",
    "role": "MyTest",
    "environment": "DEV"
  }
}

This same behaviour is exhibited when attempting to set the data at the same time as the group being created; the data, as provided by the user, should be passed through as-is - as opposed to forced into camelCase.

We can see the lack of application of the additional data, despite a HTTP/204, via the following:

$(Get-MgGroup -GroupId "ee499fb5-2107-4bcd-b488-945b48d71a74" -Property "example_Metadata").AdditionalProperties.example_Metadata | ConvertTo-JSON

Which yields,

{
  "@odata.type": "#microsoft.graph.ComplexExtensionValue"
}

When doing the same operation (i.e., setting the schema extension values) via the Graph Explorer, or directly interacting with Microsoft Graph, it works as intended - where re-running the above returns the correct values;

{
  "@odata.type": "#microsoft.graph.ComplexExtensionValue",
  "Role": "MyTest",
  "GroupOwner": "JohnDoe",
  "Environment": "DEV"
}
@ghost ghost added the ToTriage label Jun 19, 2022
@peombwa
Copy link
Member

peombwa commented Jun 21, 2022

Thanks for bringing this to our attention.

The issue is due to a serialization bug that was fixed in #1303. The fix is scheduled to go out this week as part of #1330.

@MrCaedes
Copy link
Author

Thank you @peombwa! I did have a quick search through the issues, but must have missed that one - thank you for linking it, and for the update on the release. Much appreciated!

@peombwa
Copy link
Member

peombwa commented Jun 23, 2022

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

No branches or pull requests

2 participants