datacatalog: don't drop bool_value when ordered field is present#70
Open
jbbqqf wants to merge 11 commits into
Open
datacatalog: don't drop bool_value when ordered field is present#70jbbqqf wants to merge 11 commits into
jbbqqf wants to merge 11 commits into
Conversation
…gleCloudPlatform#16856) The custom encoder for google_data_catalog_tag previously stripped boolValue from a field payload whenever the field map had more than one entry. That logic was meant to enforce the DataCatalog rule "a field contains at most one *value*-typed entry" (boolValue, stringValue, doubleValue, timestampValue, enumValue, richtextValue), but it fired indiscriminately on any companion key — including metadata such as order, displayName, or fieldName. When a tag template defines a BOOL field with a non-zero `order` (or any non-default `display_name` etc.), the user's explicit `bool_value` (typically `false`) would silently disappear from the request payload, making subsequent updates fail or behave incorrectly. Restrict the strip to the case where another *value*-typed key is also present, which is the actual conflict the API rejects. Pure metadata companions are now ignored. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a regression in the custom encoder for
google_data_catalog_tagwhere
bool_valuewas silently dropped whenever the matching field hadany companion key — including pure metadata like
order— instead ofonly when another value-typed key (
stringValue,doubleValue, …) waspresent.
Fixes hashicorp/terraform-provider-google#16856 — see hashicorp/terraform-provider-google#16856
Why
The DataCatalog API rejects a field payload that contains more than one
value-typed entry (one of
boolValue,stringValue,doubleValue,timestampValue,enumValue,richtextValue). To prevent this on theprovider side, the custom encoder added in
GoogleCloudPlatform/magic-modules#4004
strips
boolValuewhenever a field has multiple entries, on theassumption that a multi-entry field implies a value conflict.
That assumption is wrong. A user who writes:
…and then a tag with:
…produces a field map with
{boolValue: false, order: 1}after theexpand pass. The old encoder saw
len(values) > 1and strippedboolValue— even thoughorderis a metadata key, not a value-typedkey. The resulting payload had no value at all, breaking updates with
either an API error or a silent state mismatch.
Maintainer @roaks3 confirmed in the issue thread:
GCP API reference:
What changed
mmv1 custom encoder template only — replaces the unconditional
"more-than-one-key" strip with a check that at least one other
value-typed key is present. Pure metadata companions (
order,displayName,fieldName,column) no longer trigger the strip.The original "value-conflict" defense is preserved (e.g. if a user really
did set both
bool_valueandstring_valueon the same field, we stillstrip
boolValue— same as today).Edge cases tested
bool_value = false+ tag templateorder = 1boolValue: false, update succeedsboolValuestripped (preserves PR GoogleCloudPlatform#4004 behavior); onlystringValuereaches APIstring_value = "x"+order = 1stringValuereaches API;boolValuewas never present so encoder is no-opTest protocol
Resources
Disclosure
This PR was drafted with assistance from Claude Code as part of a parallel
contribution batch. The encoder change was reviewed against the
DataCatalog API documentation and against the original maintainer
acknowledgement in the issue thread. Live smoke was not run; the author
(a human) will review the diff and the modular-magician downstream PRs
before requesting maintainer review.