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

optional repeated #10489

Closed
misha-antonenko opened this issue Sep 1, 2022 · 2 comments
Closed

optional repeated #10489

misha-antonenko opened this issue Sep 1, 2022 · 2 comments
Assignees

Comments

@misha-antonenko
Copy link

misha-antonenko commented Sep 1, 2022

What language does this apply to?
If it's a proto syntax change, is it for proto2 or proto3? proto3
If it's about generated code change, what programming language?

Describe the problem you are trying to solve.

Suppose you pass around configurations as protobuf messages. You want to be able to parse configurations from JSON using util::JsonStringToMessage and override a configuration with another one using MergeFrom (so that all fields in the first one which are present in the second one are overwritten). This works fine, as long as all your fields are optional and singular. But then you want to be able to override repeated fields; in particular, you want to be able to override a non-empty list of values with an empty one. To date, this is not possible, as the representations of JSONs with "a": [] for a repeated field a are indistinguishable from representations of those where the field is not present.

Describe the solution you'd like

Support optional repeated

Describe alternatives you've considered

Wrap all repeated fields in something like

message MyMessage {}

message MyMessageList {
  repeated MyMessage values = 1;
}

Additional context
Add any other context or screenshots about the feature request here.

@misha-antonenko misha-antonenko added the untriaged auto added to all issues by default when created. label Sep 1, 2022
@perezd perezd added binary format and removed untriaged auto added to all issues by default when created. labels Sep 1, 2022
@fowles
Copy link
Member

fowles commented Sep 8, 2022

Unfortunately this has very very large implication across the entire ecosystem and is not something we would consider doing.

@fowles fowles closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2022
@misha-antonenko
Copy link
Author

At first sight this seems to admit a non-invasive implementation that would depend on a bit of syntactic sugar and do not require changes to the binary format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants