Repository navigation
fix: only use emit_default for proto messages - #75
Merged
viacheslav-rostovtsev merged 2 commits intoSep 23, 2026
Merged
viacheslav-rostovtsev merged 2 commits into
viacheslav-rostovtsev merged 2 commits into
Conversation
GrpcTranscoder#construct_body_query_params passed `emit_defaults: true` to `to_json` on whatever the `body:` template resolved to. That keyword belongs to Google::Protobuf::MessageExts#to_json; when the body template points at a scalar, enum or repeated field the call instead dispatches to the json gem's Object#to_json, which has never accepted it. json 2.x silently discarded unknown keywords, so this was invisible. json 3.x validates them and raises ArgumentError, breaking transcoding at runtime for any RPC with a scalar body binding. The gemspec does not constrain json, so nothing prevents resolving 3.x. Guard the keyword on the receiver actually being a protobuf message. Behaviour is unchanged on json 2.x, where the keyword was always a no-op on the non-message branch. The sibling call site that serialises the whole request is safe and untouched: there the receiver is always a message. Bug: b/565440846
CI already pins toys to the 0.22.x series (googleapis#74), but nothing enforced it for anyone running `toys ci` locally, so a stale or newer toys silently produced different results than CI. Declaring toys as a bundle dependency makes the pin self-enforcing: Toys::Utils::Gems#check_gemfile_compatibility evaluates the Gemfile and raises IncompatibleToysError when the running toys falls outside the declared requirement, instead of failing later in a confusing way. Note this does not make toys honour Gemfile.lock. Toys unconditionally writes a temporary Gemfile that strips every already-loaded gem from the dependency list and re-pins it to the exact version the toys process loaded, so `toys test` still exercises the newest installed versions of gems toys itself loads. Use `bundle exec` when lock fidelity matters. Resolution is otherwise unaffected: the lockfile gains only toys and toys-core, with no other version changes.
torreypayne
approved these changes
Sep 23, 2026
Member
Author
existing tests cover this and fail if you allow json3 |
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.
internal ref: b/565440846
Also pin toys in the Gemfile since we're pinning it in the CI