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

Opaque errors when token verification fails #711

Open
rawnsley opened this issue Oct 14, 2022 · 3 comments
Open

Opaque errors when token verification fails #711

rawnsley opened this issue Oct 14, 2022 · 3 comments

Comments

@rawnsley
Copy link

Problem Statement

Caveat: I am new to both Guardian and Elixir

While trying to get the decode_and_verify function working, I was thwarted by obscure error messages. In the end my problem was fixed by being explicit about the allowed algorithms, but the error returned by this function was always CaseClauseError{term: {:error, :badarg}}}

I think this is because the root error is returned by decode_token, then returning_tuple maps it to { :error, _ } (already striping out any useful info), and then the calling function has no matching case clause anyway so it throws a generic CaseClauseError.

This exception is caught in decode_and_verify and an error message is returned, but there is no chance of debugging where the failure originally occured.

I'm not sure what the right behaviour should be in this case or what is canonical Elixir, but as it stands I ended up having to reproduce the call chain line-by-line in my client code until I found the problem, which isn't ideal.

Solution Brainstorm

No response

@f-francine
Copy link

f-francine commented Nov 16, 2022

Hello, @rawnsley!
Perhaps a log message, with the original errors, would be helpful. At least it would make it easier to debug the problem

@rawnsley
Copy link
Author

@f-francine A log message would be great - thank you.

@yordis
Copy link
Member

yordis commented Nov 24, 2022

@f-francine thank you so much for the help.


@rawnsley do you mind filling up the "Solution Brainstorm" I am not sure what you are asking us to do or what you would propose.

Or even much better, since you already know how to replicate the issue and whatnot, create a PR with the proposed solution. I am here to help you with it as much as I can.

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

No branches or pull requests

3 participants