Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/azure-cli/azure/cli/command_modules/role/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def list_apps(cmd, app_id=None, display_name=None, identifier_uri=None, query_fi

result = client.applications.list(filter=(' and '.join(sub_filters)))
if sub_filters or include_all:
return result
return list(result)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result returned by client.applications.list is an Iterator. It is later used by

which will always evaluate to True.

result should be converted to a list before being evaluated by if.

Example:

it = iter([])
print(bool(it))
# True


result = list(itertools.islice(result, 101))
if len(result) == 101:
Expand Down Expand Up @@ -1415,7 +1415,6 @@ def create_service_principal_for_rbac(
existing_sps = list(graph_client.service_principals.list(filter=query_exp))
if existing_sps:
app_display_name = existing_sps[0].display_name
name = existing_sps[0].service_principal_names[0]

app_start_date = datetime.datetime.now(TZ_UTC)
app_end_date = app_start_date + relativedelta(years=years or 1)
Expand Down