protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Use FieldMaskUtil to _clear_ the fields specified in FieldMask

Open selotape opened this issue 3 years ago • 5 comments

What language does this apply to? It's relevant for any language and proto version. Specifically I had this requirement in Java and proto2.

Describe the problem you are trying to solve. My specific usecase was as follows:

There's a ubiquitous proto object my server wants to share with several other servers. But this object contains several very-big (binary/text) fields which are irrelevant for most consumers. Before sending the proto to other servers, I want to clean it up. Ideally I'd like to to this without "hard coding" the fields names (i.e. use some configuration to remove undesired fields). So I can easily add/remove fields to clean up later.

I tried using FieldMaskUtils for this, but it currently only supports "keeping" the masked fields.

Describe the solution you'd like Add to FieldMaskUtil a method which removes the fields specified in the FieldMask. i.e. the opposite of FieldMaskUtil.merge(), which keeps only the masked fields.

Describe alternatives you've considered

  1. "hard code" the fields I want to remove (this is what I chose for now)
  2. Write a custom recursive+reflective implementation of my suggestion, outside of FieldMaskUtil and without utilizing FieldMaskTree

Additional context I'd love to contribute code for this, if the feature-request is accepted

selotape avatar Jul 01 '22 07:07 selotape

Jerry, this sounds like a fairly reasonable request. Do you want to work with selotape around turning it into a proposal so he can land it?

fowles avatar Jul 01 '22 22:07 fowles

Hey, by "proposal" do you mean a PR?

Or is there another approval phase we need to go through before starting to code this?

Would you mind if I start working on a PR and we'll continue the discussion on it?

selotape avatar Jul 06 '22 07:07 selotape

Yes. I can help with this.

On Fri, Jul 1, 2022 at 4:49 PM Matt Fowles Kulukundis < @.***> wrote:

Jerry, this sounds like a fairly reasonable request. Do you want to work with selotape around turning it into a proposal so he can land it?

— Reply to this email directly, view it on GitHub https://github.com/protocolbuffers/protobuf/issues/10198#issuecomment-1172769051, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZRRDX3BN3T5I5OAHHFLP3LVR5YYBANCNFSM52OAK7WQ . You are receiving this because you were assigned.Message ID: @.***>

-- Jerry Berg | Software Engineer | @.*** | 720-808-1188

googleberg avatar Jul 06 '22 12:07 googleberg

Hi Ron,

I'm fine if you want to start on the PR. I'm new to the process as well, but I think because this is a new API dealing with fieldmasks we might need a doc. I'll clarify what's actually needed.

-Jerry

On Wed, Jul 6, 2022 at 6:00 AM Jerry Berg @.***> wrote:

Yes. I can help with this.

On Fri, Jul 1, 2022 at 4:49 PM Matt Fowles Kulukundis < @.***> wrote:

Jerry, this sounds like a fairly reasonable request. Do you want to work with selotape around turning it into a proposal so he can land it?

— Reply to this email directly, view it on GitHub https://github.com/protocolbuffers/protobuf/issues/10198#issuecomment-1172769051, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZRRDX3BN3T5I5OAHHFLP3LVR5YYBANCNFSM52OAK7WQ . You are receiving this because you were assigned.Message ID: @.***>

-- Jerry Berg | Software Engineer | @.*** | 720-808-1188

-- Jerry Berg | Software Engineer | @.*** | 720-808-1188

googleberg avatar Oct 11 '22 08:10 googleberg

Thanks,

But please start by reading shaod2s resolution to my PR. I don't want to waste your time on this if this is not feasible.

selotape avatar Oct 11 '22 08:10 selotape

@selotape: Can I check whether this issue is still important to you? I'm trying to get a handle on "everything FieldMask-related" that needs attention, so I'm looking through issues about it. If you definitely want something like this still, I can try to include it in whatever plans I come up with - but I'm also looking to limit the scope as far as I reasonably can, so if you've come up with workarounds that you're reasonably happy with, I'd prefer to just close this. Please let me know.

jskeet avatar Jul 06 '23 14:07 jskeet

This was always a nice-to-have. I've worked around this a long time ago. Feel free to close.

Thank you Jon!

On Thu, 6 Jul 2023, 17:02 Jon Skeet, @.***> wrote:

@selotape https://github.com/selotape: Can I check whether this issue is still important to you? I'm trying to get a handle on "everything FieldMask-related" that needs attention, so I'm looking through issues about it. If you definitely want something like this still, I can try to include it in whatever plans I come up with - but I'm also looking to limit the scope as far as I reasonably can, so if you've come up with workarounds that you're reasonably happy with, I'd prefer to just close this. Please let me know.

— Reply to this email directly, view it on GitHub https://github.com/protocolbuffers/protobuf/issues/10198#issuecomment-1623736808, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMXR3TOGN7Q25QFZEBCVYTXO3AO3ANCNFSM52OAK7WQ . You are receiving this because you were mentioned.Message ID: @.***>

selotape avatar Jul 06 '23 16:07 selotape

@selotape: Thanks for your understanding :) (I'll try to bear this in mind while working on other FieldMask aspects. If it happens to drop out of other work, that would be great...)

jskeet avatar Jul 06 '23 16:07 jskeet