Skip to content

Conversation

ghifari160
Copy link

m.RequireAccount checks if session is nil and only handles error when it is. When using custom implementations of SessionProvider, it is possible that the provider returns a non-nil Session when an error occurred. This pr handles the error and checks for nil Session before passing the session to the context. Also, checking for ErrNoSession is done with the standard library's errors.Is (added to the standard library in Go 1.13). This way, custom implementations of the SessionProvider interface can wrap the error if they need to provide additional context down the line.

m.RequireAccount checks if session is nil and only handles error when it
is. This is not idiomatic. Also, ErrNoSession is handled with direct
equality comparison. So, handle errors and protect against nil Session
before adding it to the request context. And when checking for
ErrNoSession, do so with errors.Is. This way, custom implementations of
SessionProvider can wrap ErrNoSession, if they so choose.
@ghifari160 ghifari160 requested a review from crewjam as a code owner May 28, 2025 01:43
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.

1 participant