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

returning errors back to the client. #990

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LennyAndersen
Copy link

Motivation

When using the pulsar go client with oauth2, setting up the auth with the function NewAuthenticationOAuth2 doesn't return an error. In case of errors in the authentication flow nothing happens and the user/developer can only assume that the authentication went well.

It turns out there is a pretty decent error handling in the entire flow, but for unknown reasons this error is discarded right before the connection is returned to the client.

Modifications

Instead of just discarding the error, it is now returned. Note that the function now returns two parameters instead of just one and should be handled accordingly.
Refer to the changelog of the file pulsar/client.go to see the actual changes.

Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

Documentation

  • Does this pull request introduce a new feature? no

Copy link
Member

@shibd shibd left a comment

Choose a reason for hiding this comment

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

@LennyAndersen Please fix the go lint related failed.

oauth, _ := auth.NewAuthenticationOAuth2WithParams(authParams)
return oauth
func NewAuthenticationOAuth2(authParams map[string]string) (Authentication, error) {
oauth, err := auth.NewAuthenticationOAuth2WithParams(authParams)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you should change the return value.

You can add a new method or use panic here.

Copy link
Author

Choose a reason for hiding this comment

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

Okay. I dont think I will do a panic/fatal or in any other way exit with an error in a function like that. But I guess that could be a matter of personal preference or coding style.

So just to be clear we're talking about the same; your suggestion would be to make another function called something like NewAuthenticationOAuth2withErrorHandling, correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

In principal, the modifications that modify the public APIs should not be accepted. /cc @shibd

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.

None yet

4 participants