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

AIP-203: How should we communicate field_behavior in a oneof? #1147

Open
noahdietz opened this issue Jun 22, 2023 · 2 comments
Open

AIP-203: How should we communicate field_behavior in a oneof? #1147

noahdietz opened this issue Jun 22, 2023 · 2 comments
Labels
aip: amendment This AIP should be amended to add something.

Comments

@noahdietz
Copy link
Collaborator

noahdietz commented Jun 22, 2023

#299 attempted to take a stance on use of field_behavior = REQUIRED on oneof fields, but it is wrong. oneof and field_behavior = REQUIRED/OPTIONAL answer different questions and impact different things. One is a serialization/wire format tool, the other is a documentation of service behavior.

That said, we still need a way to communicate service expectations of oneof fields. Unfortunately, protobuf does not have a means of annotating the oneof statement itself, leaving us with field or message level annotations, each with their own issues.

cc @toumorokoshi tracking our internal discussion from a few weeks ago.

@Fleshgrinder
Copy link

Protobuf does support annotating of oneof statements.

syntax = "proto3";

import "google/api/field_behavior.proto";
import "google/protobuf/descriptor.proto";

extend .google.protobuf.OneofOptions {
  repeated .google.api.FieldBehavior oneof_behavior = 1053;
}

message Test {
  oneof something {
    option (oneof_behavior) = REQUIRED;

    string this = 1;
    string or_this = 2;
    string but_at_least_this = 3;
  }
}

@noahdietz
Copy link
Collaborator Author

Yep you are right! I hadn't updated this issue. I actually opened #1181 to start this process but had to put it on hold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aip: amendment This AIP should be amended to add something.
Projects
None yet
Development

No branches or pull requests

2 participants