Skip to content

Commit 1a52c1d

Browse files
authored
Add nil check to exprOptions.RecaptchaOptions in google_compute_security_policy (#15125)
1 parent 634129d commit 1a52c1d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mmv1/third_party/terraform/services/compute/resource_compute_security_policy.go.tmpl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,15 +1372,24 @@ func flattenMatchExprOptions(exprOptions *compute.SecurityPolicyRuleMatcherExprO
13721372
return nil
13731373
}
13741374

1375-
// We check if the API is returning a empty non-null value then we find the current value for this field in the rule config and check if its empty
1375+
// The API can return an explicit entry `exprOptions` object, causing evaluation of the `recaptcha_options` settings to fail as it's nil: https://github.com/hashicorp/terraform-provider-google/issues/24334
1376+
// Explicitly check it's available and exit early if not.
1377+
if exprOptions.RecaptchaOptions == nil {
1378+
return nil
1379+
}
1380+
1381+
// The API can return an explicit empty rule causing an issue: https://github.com/hashicorp/terraform-provider-google/issues/16882#issuecomment-2474528447
1382+
// We check if the API is returning a empty non-null value then we find the current value for this field in the rule config and check if its empty.
13761383
if (tpgresource.IsEmptyValue(reflect.ValueOf(exprOptions.RecaptchaOptions.ActionTokenSiteKeys)) &&
13771384
tpgresource.IsEmptyValue(reflect.ValueOf(exprOptions.RecaptchaOptions.SessionTokenSiteKeys))) &&
13781385
verifyRulePriorityCompareEmptyValues(d, rulePriority, "recaptcha_options") {
13791386
return nil
13801387
}
13811388

13821389
data := map[string]interface{}{
1390+
// NOTE: when adding new entries, the recaptcha_options rule above will need to be revised
13831391
"recaptcha_options": flattenMatchExprOptionsRecaptchaOptions(exprOptions.RecaptchaOptions),
1392+
// NOTE: when adding new entries, the recaptcha_options rule above will need to be revised
13841393
}
13851394

13861395
return []map[string]interface{}{data}

0 commit comments

Comments
 (0)