-
Notifications
You must be signed in to change notification settings - Fork 3.9k
optional nullable is not working #9868
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
Comments
|
Well, if optional field can't be set to null, then why Java has the concept
of null? Idiot
Here is the progress of Dart:
google/protobuf.dart#790 (comment)
According to my experiment, Python, JavaScript, Rust, they all support to
set optional field to null or None
What do you expect? Want me to test CPP and C as well?
…On Fri, Feb 3, 2023, 3:20 AM sanjaypujare ***@***.***> wrote:
optional in proto3 does not imply nullable for the equivalent field in
the generated Java (or Kotlin) code. Specifically you should not call
setError(null) just because it is marked optional.
optional in proto3 means you can check on the receiving side to see if
the value was explicitly set as stated in Specifying Field Rules
<https://protobuf.dev/programming-guides/proto3/#specifying-field-rules>.
—
Reply to this email directly, view it on GitHub
<#9868 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEDE7LNAEN7WEQG7XHWG7GTWVQCI5ANCNFSM6AAAAAAUOP2PFA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
This seems really about the protobuf message codegen, so https://github.com/protocolbuffers/protobuf is the place you'd need to file an issue. (If it is an RPC issue then it is gRPC, if it is a message issue it is protobuf.) |
Generator version: 1.52.1
https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/1.52.1/protoc-gen-grpc-java-1.52.1-osx-x86_64.exe
Generate command:
Protocols
Kotlin code
Error
As I tested out, if I use
setError("")
, there would have no error.But if I use
setError(null)
, error happens.The text was updated successfully, but these errors were encountered: