From 09bad12091e95593b713871991182f21d83060f3 Mon Sep 17 00:00:00 2001 From: bogdanprodan-okta <71279414+bogdanprodan-okta@users.noreply.github.com> Date: Fri, 23 Jul 2021 17:42:13 +0300 Subject: [PATCH] Fixed nil pointer for Behaviors (#543) --- okta/resource_okta_policy_rule_sign_on.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/okta/resource_okta_policy_rule_sign_on.go b/okta/resource_okta_policy_rule_sign_on.go index 9bdf1aa02..064a9a8e0 100644 --- a/okta/resource_okta_policy_rule_sign_on.go +++ b/okta/resource_okta_policy_rule_sign_on.go @@ -160,14 +160,18 @@ func resourcePolicySignOnRuleRead(ctx context.Context, d *schema.ResourceData, m if rule.Actions.SignOn.FactorPromptMode != "" { _ = d.Set("mfa_prompt", rule.Actions.SignOn.FactorPromptMode) } - if rule.Conditions != nil && rule.Conditions.RiskScore != nil { - _ = d.Set("risc_level", rule.Conditions.RiskScore.Level) - } - err = setNonPrimitives(d, map[string]interface{}{ - "behaviors": convertStringSetToInterface(rule.Conditions.Risk.Behaviors), - }) - if err != nil { - return diag.Errorf("failed to set sign-on policy rule behaviors: %v", err) + if rule.Conditions != nil { + if rule.Conditions.RiskScore != nil { + _ = d.Set("risc_level", rule.Conditions.RiskScore.Level) + } + if rule.Conditions.Risk != nil { + err = setNonPrimitives(d, map[string]interface{}{ + "behaviors": convertStringSetToInterface(rule.Conditions.Risk.Behaviors), + }) + if err != nil { + return diag.Errorf("failed to set sign-on policy rule behaviors: %v", err) + } + } } if rule.Actions.SignOn.Access == "CHALLENGE" { chain := rule.Actions.SignOn.Challenge.Chain