-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
5113. Validation of oneof nested objects #5211
5113. Validation of oneof nested objects #5211
Conversation
…other oneof fields.
…table, that resets other options of the oneOf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minus the contribution guide changes, this looks great, thank you so much!
Seems like some swagger files still need to be regenerated, could you try running it again? See the failures in the |
As I understand the file shouldn't change. It seems ok now. I can't explain what happened in the previous iteration 🤷 |
Thanks for your contribution! |
References to other Issues or PRs
Fixes #5113
Have you read the Contributing Guidelines?
Yes.
Brief description of what is fixed or changed
The fix follows the suggestion from the issue. The oneOf check is moved before
msgValue.Mutable()
resets other option of this oneOf.Also, previous behavior didn't validate nested messages correctly. After the cycle "fieldDescriptor" points to a leaf of a path tree and it's not a member of a oneOf field. For example, the piece of a proto
and the path
["nested_oneof_value_one", "int32Value"]
.WhichOneof(nested_oneof_value_one)
returns nested_oneof_value, but `WhichOneof(int32Value) returns nil.Other comments
I struggled with codegen refreshing and spent quite a lot of time on a simple task. The contribution instruction does not regenerate *.pb.go files when protos are changed (and runs very slowly because it recompiles protoc). Other documentation also lacks instructions. I hope I found the correct way and it will save time for others.