Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle consistency related error that occurs possibly due to app ID collision in another tenant #109

Merged
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions msgraph/serviceprincipals.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ func (c *ServicePrincipalsClient) Create(ctx context.Context, servicePrincipal S
}

appNotReplicated := func(resp *http.Response, o *odata.OData) bool {
if resp != nil && resp.StatusCode == http.StatusBadRequest && o != nil && o.Error != nil {
return o.Error.Match(odata.ErrorServicePrincipalInvalidAppId)
if resp != nil && o != nil && o.Error != nil {
if resp.StatusCode == http.StatusBadRequest {
return o.Error.Match(odata.ErrorServicePrincipalInvalidAppId)
}
if resp.StatusCode == http.StatusForbidden {
return o.Error.Match(odata.ErrorServicePrincipalAppInOtherTenant)
}
}
return false
}
Expand Down
1 change: 1 addition & 0 deletions odata/odata.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
ErrorConflictingObjectPresentInDirectory = "A conflicting object with one or more of the specified property values is present in the directory"
ErrorResourceDoesNotExist = "Resource '.+' does not exist or one of its queried reference-property objects are not present"
ErrorRemovedObjectReferencesDoNotExist = "One or more removed object references do not exist"
ErrorServicePrincipalAppInOtherTenant = "When using this permission, the backing application of the service principal being created must in the local tenant"
ErrorServicePrincipalInvalidAppId = "The appId '.+' of the service principal does not reference a valid application object"
ErrorUnknownUnsupportedQuery = "UnknownError: Unsupported Query"
)
Expand Down