Azure / Azure/azure-rest-api-specs

`ResourceGroups_List` returns different results in two consecutive calls

Open
#7,991 0 comments 0 reactions 0 assignees View on GitHub
Mgmt Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
3d 37m
Merged PRs (30d)
446

Description

Testing script in python:
``` python
from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.resource.resources.v2018_05_01 import ResourceManagementClient
from azure.mgmt.resource.resources.v2018_05_01.models import ResourceGroup
import random
import difflib
import time
import json
import requests
import subprocess

def get_subscription_id():
cmd = "az account show"
result = subprocess.check_output(cmd, shell=True)
result_json = json.loads(result)
return result_json["id"]

def get_token():
cmd = "az account get-access-token"
result = subprocess.check_output(cmd, shell=True)
token_json = json.loads(result)
return token_json["accessToken"]

def call_list_rest(subsId, token):
url = f'https://management.azure.com/subscriptions/{subsId}/resourcegroups?api-version=2019-05-01'
headers = {"Authorization": "Bearer " + token}
response = requests.get(url, headers=headers)
names = []
if response.status_code == 200:
content_json = json.loads(response.content)
for g in content_json["value"]:
names.append(g["name"])
return names

client = get_client_from_cli_profile(ResourceManagementClient)
subsId = get_subscription_id()
token = get_token()
prefix = "test"
name = f"{prefix}-{random.randint(0, 100000)}"
parameters = ResourceGroup(
location='westus'
)
group = client.resource_groups.create_or_update(name, parameters)
time.sleep(2)
names1 = call_list_rest(subsId, token)
time.sleep(2)
names2 = call_list_rest(subsId, token)
client.resource_groups.delete(name)
for line in difflib.unified_diff(names1, names2, fromfile='first', tofile='second', lineterm='', n=0):
if prefix in line:
print(line)
```
One possible result of this script of 50 consecutive executions (using `for ($i=0; $i -le 50; $i++) {echo $i; python main.py; }`):
```
0
1
2
3
4
5
6
7
8
9
10
-test-93296
11
12
13
14
15
16
17
18
19
20
21
22
-test-85758
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
-test-58905
44
45
46
47
48
49
-test-87855
50
```
It is the second list cal that always misses a resource group.

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied Python reproduction and compare consecutive responses from the management.azure.com resource-groups endpoint. Then inspect the repository's REST API specification coverage for ResourceGroups_List. Done means identifying the source of the inconsistent results and documenting or correcting the applicable specification behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.