Skip to content

fix(runtime): parse an empty FieldMask query parameter as an empty mask - #7586

Merged
johanbrandhorst merged 1 commit into
grpc-ecosystem:mainfrom
LuisFigueroaG:fix/query-empty-field-mask
Oct 27, 2026
Merged

johanbrandhorst merged 1 commit into
grpc-ecosystem:mainfrom
LuisFigueroaG:fix/query-empty-field-mask

Conversation

@LuisFigueroaG

Copy link
Copy Markdown
Contributor

References to other Issues or PRs

No issue. Same kind of bug as #7552, but for the query string: FieldMaskFromRequestBody no 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.FieldMask query parameter is parsed with strings.Split(value, ","), and strings.Split("", ",") returns [""]. So an empty value produces a mask with one empty path:

msg := &examplepb.Proto3Message{}
_ = runtime.PopulateQueryParameters(msg, url.Values{"fieldmask_value": {""}}, utilities.NewDoubleArray(nil))
// msg.FieldmaskValue.Paths == []string{""}

A PATCH with ?update_mask= therefore reaches the backend with update_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 empty FieldMask. Non-empty values are parsed as before.

Other comments

Added TestPopulateParametersFieldMask. The empty value cases fail on main.

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 "".

@johanbrandhorst johanbrandhorst left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@johanbrandhorst
johanbrandhorst merged commit 8387556 into grpc-ecosystem:main Oct 27, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants