Skip to content

Preserve FieldMask as a message in the CelValue runtime path#1074

Open
andrewparmet wants to merge 5 commits into
google:mainfrom
andrewparmet:fix-fieldmask-celvalue
Open

Preserve FieldMask as a message in the CelValue runtime path#1074
andrewparmet wants to merge 5 commits into
google:mainfrom
andrewparmet:fix-fieldmask-celvalue

Conversation

@andrewparmet
Copy link
Copy Markdown

BaseProtoCelValueConverter.fromWellKnownProto converts FieldMask to a comma-separated string of its paths. This breaks CEL expressions that access fields on the FieldMask.

Match cel-go and ProtoLiteAdapter.adaptValueToWellKnownProto and treat FieldMask as a regular message.

BaseProtoCelValueConverter.fromWellKnownProto converts FieldMask to a
comma-separated string of its paths. That's correct in JSON-assignment
contexts (handled separately by CelProtoJsonAdapter), but it breaks CEL
expressions that access fields on the FieldMask itself — e.g.
`fieldMask.paths` — because the string has no field `paths`.

The CEL spec's WKT conversion table does not list FieldMask. cel-go
treats it as a regular message, as does cel-java's legacy
ProtoLiteAdapter.adaptValueToWellKnownProto for non-JSON contexts.
Override fromWellKnownProto in ProtoCelValueConverter to preserve
FieldMask as a ProtoMessageValue. JSON-assignment paths (e.g.
TestAllTypes{single_value: FieldMask{...}}) are unaffected because
EvalCreateStruct and CelValueRuntimeTypeProvider.createMessage both
unwrap StructValue results before the outer assignment runs, and the
outer assignment goes through CelProtoJsonAdapter.adaptValueToJsonValue
which handles FieldMask → string conversion at that layer.
Move the FieldMask case into BaseProtoCelValueConverter, delegating to a new
fromProtoMessageToStructValue hook that both the full and lite converters
implement. This reuses the existing non-well-known message wrapping path
(removing the duplicated ProtoMessageValue.create call) and extends the fix to
the lite runtime. Adds a lite-converter test.
Mirror the full converter: intercept FIELD_MASK in the lite converter and wrap
it as a ProtoMessageLiteValue so it is navigable as a message on the lite
runtime. Adds a lite-converter test.
@l46kok l46kok added the ready to pull Pulls the pending PR into Critique label Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to pull Pulls the pending PR into Critique

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants