-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: allow ForceSendFields to work for map types #2670
Merged
Merged
Conversation
This file contains 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
The way we generate map types today is map[string]T, where T is a non-pointer type. This means the value receiver version of MarshalJSON does not fullfill the Marshaler interface. This is turn means that MarshalJSON is not called in these cases so ForceSendFields overrides do not work. To fix this we can switch the impl to a value reciever which fullfills both value and pointer types. This is not a breaking change for the API, but there is a slight behaviour change if someone was calling MarshalJSON directly. Nil *T's that call MarshalJSON directly will now panic instead of returning JSON `null`. This seems like unlikely usage and worth breaking to fix a bug in common usage.
noahdietz
approved these changes
Jul 3, 2024
tritone
approved these changes
Jul 3, 2024
nit: The description looks to be a bit misleading. I think you mean the pointer receiver version of MarshalJSON. |
/lgtm Thanks for the quick fix! |
shollyman
approved these changes
Jul 8, 2024
codyoss
added
the
automerge
Merge the pull request once unit tests and other checks pass.
label
Jul 8, 2024
gcf-merge-on-green
bot
removed
the
automerge
Merge the pull request once unit tests and other checks pass.
label
Jul 8, 2024
gcf-merge-on-green bot
pushed a commit
that referenced
this pull request
Jul 9, 2024
🤖 I have created a release *beep* *boop* --- ## [0.188.0](https://togithub.com/googleapis/google-api-go-client/compare/v0.187.0...v0.188.0) (2024-07-09) ### Features * **all:** Auto-regenerate discovery clients ([#2665](https://togithub.com/googleapis/google-api-go-client/issues/2665)) ([e84fa65](https://togithub.com/googleapis/google-api-go-client/commit/e84fa6508ebc498c3435668c48001185fbc9ce83)) * **all:** Auto-regenerate discovery clients ([#2669](https://togithub.com/googleapis/google-api-go-client/issues/2669)) ([6df3749](https://togithub.com/googleapis/google-api-go-client/commit/6df37492965b6323c6bcefa2a1ccd192b92981b4)) * **all:** Auto-regenerate discovery clients ([#2671](https://togithub.com/googleapis/google-api-go-client/issues/2671)) ([0d54a85](https://togithub.com/googleapis/google-api-go-client/commit/0d54a8540060cc79f830892fdd1fba46d73034c1)) * **all:** Auto-regenerate discovery clients ([#2673](https://togithub.com/googleapis/google-api-go-client/issues/2673)) ([88240e3](https://togithub.com/googleapis/google-api-go-client/commit/88240e3d98f3e944398c50379372eb071ebac0a2)) * **all:** Auto-regenerate discovery clients ([#2674](https://togithub.com/googleapis/google-api-go-client/issues/2674)) ([d465cec](https://togithub.com/googleapis/google-api-go-client/commit/d465cec68dbc2616c665e6ea240cd1e32c01418d)) * **all:** Auto-regenerate discovery clients ([#2675](https://togithub.com/googleapis/google-api-go-client/issues/2675)) ([a9177bd](https://togithub.com/googleapis/google-api-go-client/commit/a9177bdbdbba60c86b22bda4a7061c31d3485e4a)) * **all:** Auto-regenerate discovery clients ([#2677](https://togithub.com/googleapis/google-api-go-client/issues/2677)) ([5dd2fb2](https://togithub.com/googleapis/google-api-go-client/commit/5dd2fb237802349250c97c0ebdbb54cbd088884d)) * **all:** Auto-regenerate discovery clients ([#2678](https://togithub.com/googleapis/google-api-go-client/issues/2678)) ([d17f6be](https://togithub.com/googleapis/google-api-go-client/commit/d17f6beb5a531910b563a4383acaa383dbd3ee43)) ### Bug Fixes * Allow ForceSendFields to work for map types ([#2670](https://togithub.com/googleapis/google-api-go-client/issues/2670)) ([40b5113](https://togithub.com/googleapis/google-api-go-client/commit/40b5113127c4d66d533df16fe201898855c7c0cc)) * Check []bytes > 0 instead of nil ([#2667](https://togithub.com/googleapis/google-api-go-client/issues/2667)) ([711eb91](https://togithub.com/googleapis/google-api-go-client/commit/711eb913fe455ffe5c9d717b44762801820c0e8c)), refs [#2647](https://togithub.com/googleapis/google-api-go-client/issues/2647) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
abs3ntdev
pushed a commit
to abs3ntdev/gspot
that referenced
this pull request
Jul 10, 2024
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [google.golang.org/api](https://github.com/googleapis/google-api-go-client) | require | minor | `v0.187.0` -> `v0.188.0` | --- ### Release Notes <details> <summary>googleapis/google-api-go-client (google.golang.org/api)</summary> ### [`v0.188.0`](https://github.com/googleapis/google-api-go-client/releases/tag/v0.188.0) [Compare Source](googleapis/google-api-go-client@v0.187.0...v0.188.0) ##### Features - **all:** Auto-regenerate discovery clients ([#​2665](googleapis/google-api-go-client#2665)) ([e84fa65](googleapis/google-api-go-client@e84fa65)) - **all:** Auto-regenerate discovery clients ([#​2669](googleapis/google-api-go-client#2669)) ([6df3749](googleapis/google-api-go-client@6df3749)) - **all:** Auto-regenerate discovery clients ([#​2671](googleapis/google-api-go-client#2671)) ([0d54a85](googleapis/google-api-go-client@0d54a85)) - **all:** Auto-regenerate discovery clients ([#​2673](googleapis/google-api-go-client#2673)) ([88240e3](googleapis/google-api-go-client@88240e3)) - **all:** Auto-regenerate discovery clients ([#​2674](googleapis/google-api-go-client#2674)) ([d465cec](googleapis/google-api-go-client@d465cec)) - **all:** Auto-regenerate discovery clients ([#​2675](googleapis/google-api-go-client#2675)) ([a9177bd](googleapis/google-api-go-client@a9177bd)) - **all:** Auto-regenerate discovery clients ([#​2677](googleapis/google-api-go-client#2677)) ([5dd2fb2](googleapis/google-api-go-client@5dd2fb2)) - **all:** Auto-regenerate discovery clients ([#​2678](googleapis/google-api-go-client#2678)) ([d17f6be](googleapis/google-api-go-client@d17f6be)) ##### Bug Fixes - Allow ForceSendFields to work for map types ([#​2670](googleapis/google-api-go-client#2670)) ([40b5113](googleapis/google-api-go-client@40b5113)) - Check \[]bytes > 0 instead of nil ([#​2667](googleapis/google-api-go-client#2667)) ([711eb91](googleapis/google-api-go-client@711eb91)), refs [#​2647](googleapis/google-api-go-client#2647) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MjYuMiIsInVwZGF0ZWRJblZlciI6IjM3LjQyNi4yIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=--> Co-authored-by: Renovate Bot <renovate-bot@gitea.com> Reviewed-on: https://git.asdf.cafe/abs3nt/gspot/pulls/17
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.
The way we generate map types today is map[string]T, where T is a non-pointer type. This means the pointer receiver version of MarshalJSON does not fulfill the Marshaler interface. This is turn means that MarshalJSON is not called in these cases so ForceSendFields overrides do not work. To fix this we can switch the impl to a value receiver which fulfills both value and pointer types. This is not a breaking change for the API, but there is a slight behaviour change if someone was calling MarshalJSON directly. Nil *T's that call MarshalJSON directly will now panic instead of returning JSON
null
. This seems like unlikely usage and worth breaking to fix a bug in common usage.Internal Bug: 349580049