Skip to content

Deserialization of additionalProperties in ComplexTypes #388

Closed

Description

@peombwa

Deserialization of additionalProperties in ComplexTypes is not properly handled by AutoREST i.e. all the properties of a ComplexType are deserialized to additionalProperties. This causes to a duplicate key error when a complexType object is reused in a request.

Repro Steps

$user = Get-MGUser -Top 1 -Property Id, Identities

# You'll notice all `ObjectIdentity` properties are deserialized in additionalProperties.

$user.Identities | ft SignInType, Issuer, IssuerAssignedId, AdditionalProperties
SignInType        Issuer     IssuerAssignedId      AdditionalProperties
----------        ------     ----------------      --------------------
userPrincipalName deleted     deleted              {[signInType, userPrincipalName], [issuer, deleted], [issuerAssignedId, deleted]}

# Reuse $user
Update-MgUser -UserId $anotherUserId -Manager $users
Update-MgUser_UpdateExpanded1: An item with the same key has already been added. Key: issuer

Activity

  1. peombwa commented on Sep 19, 2020

    @peombwa
    MemberAuthor

    This can be mitigated by a directive to fix AutoREST's serialization layer. AutoREST is simply not passing properties to be excluded from additionalProperties when deserializing complex types.

  2. darrelmiller commented on Sep 21, 2020

    @darrelmiller
    Contributor

    I believe the issue here is that -Manager is not a valid property for updates. Navigation properties should not be exposed for update models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions