Azure / Azure/azure-rest-api-specs

[Authorization] Model validation fails with errors

Open
#765 1 comment 0 reactions 0 assignees View on GitHub
Authorization internal-ms P1 Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
3d 2h
Merged PRs (30d)
424

Description

Running validation for authorization spec against examples from .net sdk tests recordings:
**Error 1**
> Operation: Permissions_ListForResourceGroup
> x-ms-examples
> Scenario: GetNonExistentResourceGroupPermissionsGET21
> InnerErrors:
1. code: INVALID_TYPE
message: Expected type string but found type null
path: nextLink
description: The URL to use for getting the next set of results.

From swagger:
```json
"PermissionGetResult": {
"properties": {
"value": {
"type": "array",
"items": {
"$ref": "#/definitions/Permission"
},
"description": "An array of permissions."
},
"nextLink": {
"type": "string",
"description": "The URL to use for getting the next set of results."
}
},
"description": "Permissions information."
}
```
Example :
```json
{
"parameters": {
"subscriptionId": "4004a9fd-d58e-48dc-aeb2-4a4aec58606f",
"resourceGroupName": "NonExistentResourceGroup",
"api-version": "2015-07-01"
},
"responses": {
"200": {
"body": {
"value": [
{
"actions": [
"*"
],
"notActions": []
}
],
"nextLink": null
}
```

Other models with similar error: RoleAssignmentListResult, RoleDefinitionListResult.

**Error 2**
> Operation: RoleDefinitions_Delete
> x-ms-examples
> Scenario: RoleDefinitionCreateTestsDELETE129
> InnerErrors:
1. code: INVALID_TYPE
message: Expected type array but found type null
path: properties,permissions,0,notActions
description: Denied actions.

From example:
```json
{
"parameters": {
"scope": "",
"roleDefinitionId": "Microsoft.Authorization",
"api-version": "2015-07-01"
},
"responses": {
"200": {
"body": {
"properties": {
"roleName": "NewRoleName_2b744e95-362a-486e-86a3-83b675ef380c",
"type": "CustomRole",
"description": "New Test Custom Role",
"assignableScopes": [
"/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f"
],
"permissions": [
{
"actions": [
"Microsoft.Authorization/*/Read"
],
"notActions": null
}
],
"createdOn": "2015-11-30T06:51:31.2296913Z",
"updatedOn": "2015-11-30T06:51:31.2296913Z",
"createdBy": "f8d526a0-54eb-4941-ae69-ebf4a334d0f0",
"updatedBy": "f8d526a0-54eb-4941-ae69-ebf4a334d0f0"
},
"id": "/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/providers/Microsoft.Authorization/roleDefinitions/2b744e95-362a-486e-86a3-83b675ef380c",
"type": "Microsoft.Authorization/roleDefinitions",
"name": "2b744e95-362a-486e-86a3-83b675ef380c"
}
}
}
}
```
From swagger - model for Permissions:
```json
"Permission": {
"properties": {
"actions": {
"type": "array",
"items": {
"type": "string"
},
"description": "Allowed actions."
},
"notActions": {
"type": "array",
"items": {
"type": "string"
},
"description": "Denied actions."
}
},
"description": "Role definition permissions."
}
```

Contributor guide

Open the contributing guide

Research direction

Review the Authorization swagger definitions for PermissionGetResult, RoleAssignmentListResult, RoleDefinitionListResult, and Permission alongside the cited x-ms-examples for Permissions_ListForResourceGroup and RoleDefinitions_Delete. Run the model validation against these recordings and confirm that the reported null nextLink and notActions values no longer produce INVALID_TYPE errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
api, authorization, backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.