Azure / azure-sdk-for-go

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:
https://docs.microsoft.com/azure/developer/go/
MIT License
1.64k stars 844 forks source link

Why does `(*armauthorization.RoleDefinitionsClient).Get` return a slice of pointers to `Permission` struct instead of a single struct? #22050

Open mattwelke opened 11 months ago

mattwelke commented 11 months ago

Bug Report

The method used to call the Role Definitions - Get endpoint seems to return data in a more complex way than is needed. And it makes me feel nervous about making software that relies on the returned data.

I decided to post on Stack Overflow because I felt this issue may relate to the Azure API as a whole, not just the Go SDK, and usually I like to get answers to questions as public as possible so that as many people as possible benefit when they're answered.

For details, see https://stackoverflow.com/questions/77534305/why-does-azures-role-definitions-api-return-more-than-permission-struct-for-a-r. If you'd rather I copy the details into this issue, just let me know!

raych1 commented 11 months ago

@mattwelke , the schema defined in swagger for the permissions field is an array. However, I validated a few roles that ends up having only one element in the array of permissions. This is an example:

"properties": {
    "roleName": "Storage Table Data Contributor",
    "type": "BuiltInRole",
    "description": "Allows for read, write and delete access to Azure Storage tables and entities",
    "assignableScopes": [
      "/"
    ],
    "permissions": [
      {
        "actions": [
          "Microsoft.Storage/storageAccounts/tableServices/tables/read",
          "Microsoft.Storage/storageAccounts/tableServices/tables/write",
          "Microsoft.Storage/storageAccounts/tableServices/tables/delete"
        ],
        "notActions": [],
        "dataActions": [
          "Microsoft.Storage/storageAccounts/tableServices/tables/entities/read",
          "Microsoft.Storage/storageAccounts/tableServices/tables/entities/write",
          "Microsoft.Storage/storageAccounts/tableServices/tables/entities/delete",
          "Microsoft.Storage/storageAccounts/tableServices/tables/entities/add/action",
          "Microsoft.Storage/storageAccounts/tableServices/tables/entities/update/action"
        ],
        "notDataActions": []
      }
    ],
    "createdOn": "2021-06-15T06:51:59.8207610Z",
    "updatedOn": "2021-11-11T20:15:12.2854966Z",
    "createdBy": null,

I'm not sure what is the real implementation in API side, and I would like to loop in the service team to confirm.

github-actions[bot] commented 11 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AshishGargMicrosoft @darshanhs90.

github-actions[bot] commented 11 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AshishGargMicrosoft @darshanhs90.

mattwelke commented 11 months ago

Thanks @raych1. Looking forward to an update from them.

However, I validated a few roles that ends up having only one element in the array of permissions. This is an example

Can you confirm whether this means you were able to find one or more roles that have more than one element in the array of permissions? If so, can you show me an example?

raych1 commented 11 months ago

Thanks @raych1. Looking forward to an update from them.

However, I validated a few roles that ends up having only one element in the array of permissions. This is an example

Can you confirm whether this means you were able to find one or more roles that have more than one element in the array of permissions? If so, can you show me an example?

@mattwelke, for all the roles I verified, I saw the response only contains one element in the permissions array.