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

protovalidate: avoid pointer comparisons #715

Merged
merged 5 commits into from
May 27, 2024

Conversation

akshayjshah
Copy link
Contributor

Changes

  • Change the logic used in WithIgnoreMessages to avoid fragile pointer
    comparisons. Instead, we match messages using their fully-qualified names.
  • Mention error details in the interceptor docstrings.
  • Make the tests more robust by asserting whether or not the service
    implementation should be called.

Verification

The unit tests should fully exercise the changes made.

Signed-off-by: Akshay Shah <akshay@akshayshah.org>
When deciding whether the user has bypassed validation for a message, we
should compare the message's fully-qualified name rather than doing a
fragile pointer comparison.

Along the way, this commit removes some puzzling and unused code to
plumb a context through the wrappedServerStream.

Signed-off-by: Akshay Shah <akshay@akshayshah.org>
For completeness, the tests should assert whether the server
implementation is actually called or not.

Signed-off-by: Akshay Shah <akshay@akshayshah.org>
Signed-off-by: Akshay Shah <akshay@akshayshah.org>
type wrappedServerStream struct {
grpc.ServerStream
// wrappedContext is the wrapper's own Context. You can assign it.
wrappedContext context.Context
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field wasn't used anywhere, so I deleted it. 🤷🏽‍♂️

Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks great, mind adding some comments?

interceptors/protovalidate/options.go Show resolved Hide resolved
Signed-off-by: Akshay Shah <akshay@akshayshah.org>
@johanbrandhorst johanbrandhorst merged commit 3606823 into grpc-ecosystem:main May 27, 2024
5 checks passed
@johanbrandhorst
Copy link
Collaborator

Thanks for your contribution!

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

Successfully merging this pull request may close these issues.

2 participants