Skip to content
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

FlatteningDeSerializer fails to deserialize objects only containing "@odata.type" field #613

Open
crachmanin opened this issue May 24, 2019 · 0 comments

Comments

@crachmanin
Copy link
Contributor

When attempting to deserialize a json object only containing a type discriminator, the FlatteningDeserializer fails with the following error:

Cannot deserialize instance of <OBJECT_NAME> out of VALUE_NULL token

So when attempting to deserialize the following string

{
    "name": "SharedContentKeyPolicyUsedByAllAssets2",
    "id": "/subscriptions/b2c12710-ecdf-4532-9ba6-7e74a219b5f2/resourceGroups/mpusw2/providers/Microsoft.Media/mediaservices/krishndurpv3/contentKeyPolicies/SharedContentKeyPolicyUsedByAllAssets2",
    "type": "Microsoft.Media/mediaservices/contentKeyPolicies",
    "properties": {
        "policyId": "5a662975-4918-4c6d-a595-01e08330f5f2",
        "created": "2019-05-22T21:47:22.427Z",
        "lastModified": "2019-05-23T01:01:22.497Z",
        "options": [
            {
                "policyOptionId": "eff2f987-2251-40ee-a5b9-f9baba86595b",
                "configuration": {
                    "@odata.type": "#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration"
                },
                "restriction": {
                    "@odata.type": "#Microsoft.Media.ContentKeyPolicyTokenRestriction",
                    "issuer": "myIssuer",
                    "audience": "myAudience",
                    "primaryVerificationKey": {
                        "@odata.type": "#Microsoft.Media.ContentKeyPolicySymmetricTokenKey"
                    },
                    "alternateVerificationKeys": [],
                    "requiredClaims": [
                        {
                            "claimType": "urn:microsoft:azure:mediaservices:contentkeyidentifier"
                        }
                    ],
                    "restrictionTokenType": "Jwt"
                }
            }
        ]
    }
}

The following error occurs:
Cannot deserialize instance of com.microsoft.azure.management.mediaservices.v2018_07_01.ContentKeyPolicyClearKeyConfiguration out of VALUE_NULL token

Since the configuration object only contains the type discriminator.

If I modify the json while debugging so that there is an additional field:

"configuration": {
                    "@odata.type": "#Microsoft.Media.ContentKeyPolicyClearKeyConfiguration",
                    "test_data": "test"
                 }

The deserialization is successful.

This issue prevent users from creating ContentKeyPolicy objects using the Java SDK generated for Azure Media Services (see https://github.com/Azure/azure-sdk-for-java/tree/master/mediaservices/resource-manager/v2018_07_01 beta 3 version)

crachmanin added a commit to crachmanin/autorest-clientruntime-for-java that referenced this issue May 25, 2019
Updating FlatteningDeserializer to handle objects that only contain
"@odata.type" field and no additional properties
praries880 added a commit that referenced this issue May 28, 2019
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

1 participant