Skip to content

Commit

Permalink
Log a warning when we suppress a 401.
Browse files Browse the repository at this point in the history
  • Loading branch information
monde committed Nov 15, 2022
1 parent c4a9645 commit 4a66add
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion okta/resource_okta_idp_saml.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func resourceIdpSamlRead(ctx context.Context, d *schema.ResourceData, m interfac
_ = d.Set("issuer_mode", idp.IssuerMode)
}
mapping, resp, err := getProfileMappingBySourceID(ctx, idp.Id, "", m)
if err := suppressErrorOn401(resp, err); err != nil {
if err := suppressErrorOn401("resource okta_idp_saml.user_type_id", m, resp, err); err != nil {
return diag.Errorf("failed to get SAML identity provider profile mapping: %v", err)
}
if mapping != nil {
Expand Down
6 changes: 4 additions & 2 deletions okta/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,11 @@ func suppressErrorOn404(resp *okta.Response, err error) error {
return responseErr(resp, err)
}

// Useful shortcut for suppressing errors from Okta's SDK when a Org does not have permission to access a feature.
func suppressErrorOn401(resp *okta.Response, err error) error {
// Useful shortcut for suppressing errors from Okta's SDK when a Org does not
// have permission to access a feature.
func suppressErrorOn401(what string, meta interface{}, resp *okta.Response, err error) error {
if resp != nil && resp.StatusCode == http.StatusUnauthorized {
logger(meta).Warn(fmt.Sprintf("Suppressing %q on %q", "401 Unauthorized", what))
return nil
}
return responseErr(resp, err)
Expand Down

0 comments on commit 4a66add

Please sign in to comment.