Skip to content

[BUG] Empy principalId and/or tenandId in identity section of GenericResource causes null error exception #31693

@lukerogers

Description

@lukerogers

Library name and version

Azure.ResourceManager 1.3.1

Describe the bug

When loading a generic resource, some of them return an "identity" section with the following payload:

"identity": {
    "principalId": "",
    "tenantId": "",
    "type": "None"
}

It throws a null error for both principalId and tenantId.

Expected behavior

The resource is able to be loaded correctly

Actual behavior

SystemFormatException: One of the identified items was in an invalid format.

The exception is thrown in https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/Models/ManagedServiceIdentity.Serialization.cs on lines 58 and 68.

So far I've come across this on 2 resources, and here are their payloads with extra stuff removed:

{
    "value": [
        {
            "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.DevTestLab/labs/{labName}",
            "name": "{labName}",
            "type": "Microsoft.DevTestLab/labs",
            "location": "eastus2",
            "identity": {
                "principalId": "",
                "tenantId": "",
                "type": "None"
            }
        }
    ]
},
{
    "value": [
        {
            "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.CognitiveServices/accounts/{name}",
            "name": "{name}",
            "type": "Microsoft.CognitiveServices/accounts",
            "sku": {
                "name": "S1"
            },
            "kind": "TextTranslation",
            "location": "northeurope",
            "identity": {
                "principalId": "",
                "tenantId": "",
                "type": "None"
            }
        }
    ]
}

Reproduction Steps

I included the payload I am receiving from the Azure REST API. I don't know if something needs to change with the model, annotations, or something else to make this work correctly.

I did open #31633 for the same issue in the PolicyInsights library. I'm guessing they are related and have the same fix.

Environment

I'm running this on Windows 11 with .NET version 6.0.9 and Visual Studio 2022

Metadata

Metadata

Assignees

Labels

ARMMgmtThis issue is related to a management package.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions