Repository navigation
fix(runtime): parse an empty FieldMask query parameter as an empty mask - #7586
Merged
johanbrandhorst merged 1 commit intoOct 27, 2026
Merged
johanbrandhorst merged 1 commit into
johanbrandhorst merged 1 commit into
Conversation
strings.Split("", ",") returns [""], so ?update_mask= populated the
field with a mask holding a single empty path. A server that validates
the mask (e.g. fieldmaskpb.IsValid) then rejects a request that only
says "update nothing".
Leave the paths empty when the value is empty, which is also how
protojson decodes "".
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.
References to other Issues or PRs
No issue. Same kind of bug as #7552, but for the query string:
FieldMaskFromRequestBodyno longer adds an empty path for{}, while?update_mask=still does.Have you read the Contributing Guidelines?
Yes
Brief description of what is fixed or changed
A
google.protobuf.FieldMaskquery parameter is parsed withstrings.Split(value, ","), andstrings.Split("", ",")returns[""]. So an empty value produces a mask with one empty path:A PATCH with
?update_mask=therefore reaches the backend withupdate_mask: {paths: [""]}, and a server that validates the mask (e.g.fieldmaskpb.IsValid) rejects it.With this change an empty value gives an empty mask (the field is still set, just with no paths). That matches protojson, which decodes
""into an emptyFieldMask. Non-empty values are parsed as before.Other comments
Added
TestPopulateParametersFieldMask. The empty value cases fail onmain.