Skip to content

Commit

Permalink
🐛 Remove infinite loop following suggestion from @JimMadge
Browse files Browse the repository at this point in the history
Co-authored-by: Jim Madge <[email protected]>
  • Loading branch information
jemrobinson and JimMadge committed Apr 11, 2024
1 parent 40f7bf3 commit f627151
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion data_safe_haven/external/api/graph_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,20 @@ def create_application(
self.grant_application_role_permissions(application_name, scope)
for scope in delegated_scopes:
self.grant_delegated_role_permissions(application_name, scope)
while True:
attempts = 0
max_attempts = 5
while attempts < max_attempts:
if application_sp := self.get_service_principal_by_name(
application_name
):
if self.read_application_permissions(application_sp["id"]):
break
time.sleep(10)
attempts += 1

if attempts == max_attempts:
msg = "Maximum attempts to validate service principle permissions exceeded"
raise DataSafeHavenMicrosoftGraphError(msg)

# Return JSON representation of the AzureAD application
return json_response
Expand Down

0 comments on commit f627151

Please sign in to comment.