-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fixed error when a boolean field set to false #4004
Conversation
Hello! I am a robot who works on Magic Modules PRs. I have detected that you are a community contributor, so your PR will be assigned to someone with a commit-bit on this repo for initial review. Thanks for your contribution! A human will be with you soon. @c2thorn, please review this PR or find an appropriate assignee. |
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 2 files changed, 129 insertions(+), 1 deletion(-)) |
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=147951" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this approach extensible to the false values for other types? double_value = 0, string_value = "", etc? Or is the bool_value the only one we need this for?
This is only for bool_value. The root cause is |
Right - but won't we also have this problem with the other types? |
fields := obj["fields"].(map[string]interface{}) | ||
for _, elements := range fields { | ||
values := elements.(map[string]interface{}) | ||
if len(values) > 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to remove user-set boolValues, and even ones that are set to True? Even though we are enacting the API's rules, we should either validate during plan or let the user's bad configuration return an error, not change their values underneath the hood.
I think this encoder solves the problem of sending too many boolValue's, but checking if the user has set the field using d.GetOkExists()
would do better here to make sure we are carrying out the user's intent. We can check if the value is set, and if not, delete it. How does that sound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually backtracking on this: we can't use d.GetOkExists()
because fields
is a set and cannot be indexed. Don't really know any other way of tell the difference between user set/unset. Do you @ndmckinley ?
We stick with this original approach and only remove if the bool_value is false? Seems slightly better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing sticks out to me. Maybe we should pause this for a day or two and think on it, let it percolate, bring it up in the next Monday meeting if we haven't thought of anything clever by then. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the API only except 1 value for fields
? If so we can use One-of validation to make sure the user isn't setting multiple values. Then we are free to delete the extra boolean values in this encoder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the API only take 1 value for each fields. But there is no way to distinguish between empty
and false
for bool, along with other value
types.
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 2 files changed, 130 insertions(+), 1 deletion(-)) |
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=149810" |
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 2 files changed, 130 insertions(+), 1 deletion(-)) |
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=149814" |
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 2 files changed, 129 insertions(+), 1 deletion(-)) |
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=149823" |
I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccProviderMeta_setModuleName|TestAccComputeSnapshot_encryptionCMEK|TestAccContainerCluster_withSandboxConfig|TestAccContainerNodePool_withSandboxConfig|TestAccMonitoringDashboard_basic|TestAccMonitoringDashboard_gridLayout|TestAccMonitoringDashboard_rowLayout|TestAccMonitoringDashboard_update You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=149825" |
Fixes hashicorp/terraform-provider-google#7097
If this PR is for Terraform, I acknowledge that I have:
make test
andmake lint
to ensure it passes unit and linter tests.Release Note Template for Downstream PRs (will be copied)