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" |
nat-henderson
left a comment
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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.
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.
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.
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.
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 testandmake lintto ensure it passes unit and linter tests.Release Note Template for Downstream PRs (will be copied)