Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to occurrence details require an invalid field mask #68

Open
alexashley opened this issue Apr 9, 2021 · 0 comments
Open

Updates to occurrence details require an invalid field mask #68

alexashley opened this issue Apr 9, 2021 · 0 comments

Comments

@alexashley
Copy link
Contributor

From this discussion: rode/collector-build#4 (comment)

Occurrence details vary depending on the kind and so are implemented using a oneof field in the protobuf definition

Generally, oneof fields aren't treated as part of the message and instead the actual name of the set field is used. For instance, there's no details field when using protojson to serialize an occurrence. They also shouldn't appear in field masks.

However, the fieldmask-utils library used in occurrence updates requires that to be passed, see this issue for more details:

https://github.com/mennanov/fieldmask-utils/pull/15

This is easy to work around when calling Grafeas using gRPC; however, it's more of an issue with HTTP requests. Because of the design of the Grafeas protos, it's not possible to pass the field mask in the request; instead gRPC gateway fills in the mask automatically based on the request body.

As a result it doesn't seem possible to update the details of an occurrence using HTTP.

In terms of fixing it there doesn't seem to be an official method for merging that takes into account the field mask. See this issue:

https://github.com/golang/protobuf/issues/1296

There's a proto.Merge function; however it doesn't take a field mask. Its behavior is also such that arrays are concatenated, rather than replaced and that's not configurable.

It might be easiest to use something like mergo to handle the actual merge and then see what options are available for filtering the request body using the field mask.

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

No branches or pull requests

1 participant