Skip to content

compute: fix preview=false updates for OrganizationSecurityPolicyRule#18079

Open
sumanth-g31 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
sumanth-g31:fix-org-security-policy-preview-false
Open

compute: fix preview=false updates for OrganizationSecurityPolicyRule#18079
sumanth-g31 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
sumanth-g31:fix-org-security-policy-preview-false

Conversation

@sumanth-g31

@sumanth-g31 sumanth-g31 commented Jun 25, 2026

Copy link
Copy Markdown

Fixes hashicorp/terraform-provider-google#27885

Summary

This change adds send_empty_value: true to the preview field of
OrganizationSecurityPolicyRule.

Without this annotation, the generated Terraform provider treats
preview = false as an empty value and omits it from create and update
requests. As a result, users cannot reliably update a rule from:

preview = true

to

preview = false

because the PATCH request does not include the preview field.

Root cause

The generated provider code used the condition:

!tpgresource.IsEmptyValue(reflect.ValueOf(v))

Since IsEmptyValue() considers the boolean value false to be empty,
preview = false was filtered out and never added to the request body.

Adding send_empty_value: true causes Magic Modules to generate:

ok || !reflect.DeepEqual(v, previewProp)

which preserves explicitly configured false values.

compute: fixed an issue where `preview = false` updates for `google_compute_organization_security_policy_rule` were omitted from API requests.

Verification

  • Added send_empty_value: true to the preview property in OrganizationSecurityPolicyRule.yaml.
  • Regenerated the Terraform provider.
  • Verified that the generated resource_compute_organization_security_policy_rule.go
    now includes preview whenever it is explicitly configured, including false.
  • Verified that the generated behavior now matches the existing implementation for
    SecurityPolicyRule and RegionSecurityPolicyRule.

Background

I initially investigated this issue in hashicorp/terraform-provider-google and opened hashicorp/terraform-provider-google#28000.

As suggested by @melinath in that PR, this fix has been moved to Magic Modules since the provider code is generated from this repository.

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jun 25, 2026
@google-cla

google-cla Bot commented Jun 25, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions

Copy link
Copy Markdown

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@rileykarson, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@github-actions github-actions Bot requested a review from rileykarson June 25, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-approval Pull requests that need reviewer's approval to run presubmit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google_compute_organization_security_policy_rule fails to update preview from true to false (unexpected new value cty.True)

2 participants