Somewhat similar to #370, we recently experienced a situation where the database was stuck in a read-only mode after a failover.
Sign-in was failing with an unhelpful message:
** (MatchError) no match of right hand side value: :error
lib/ash_authentication/strategies/password/sign_in_preparation.ex:132 AshAuthentication.Strategy.Password.SignInPreparation.generate_token/3
The SignInPreparation.generate_token fails with MatchError if Jwt.token_for_user returns :error due to being unable to store the token.
Ideally these functions that we expect to rarely fail (like generating a token) would use ! variants of any actions they call rather than failing to match on :error returns, so that a more detailed exception is recorded.
Somewhat similar to #370, we recently experienced a situation where the database was stuck in a read-only mode after a failover.
Sign-in was failing with an unhelpful message:
The
SignInPreparation.generate_token
fails with MatchError ifJwt.token_for_user
returns:error
due to being unable to store the token.Ideally these functions that we expect to rarely fail (like generating a token) would use
!
variants of any actions they call rather than failing to match on:error
returns, so that a more detailed exception is recorded.The
reason
is lost in theelse
clause of thewith
expression at: https://github.com/team-alembic/ash_authentication/blob/main/lib/ash_authentication/jwt.ex#L116