flask-jwt-extended icon indicating copy to clipboard operation
flask-jwt-extended copied to clipboard

Original error messages lost

Open JustElectron opened this issue 3 years ago • 2 comments

All error handler callbacks should include the original error message in the parameters. E.g, the _expired_token_callback takes e.jwt_header, e.jwt_data as parameters, thus the original error message is lost when setting the expired_token_loader. Either the entire error should be set as parameter, I.e. _expired_token_callback(e: Exception) or alternatively you could add the error message as a string _expired_token_callback(e.jwt_header, e.jwt_data, str(e)). The same applies for all error handlers which do not include the error message.

JustElectron avatar Jul 14 '22 08:07 JustElectron

If you don't mind me asking, what is the use case you are trying to accomplish by having access to those strings? My first thought is that if those strings are passed into the callbacks, people might try to do some kind of conditional logic based on those strings, which means it would be hard for them to be changed in the future which I don't love.

vimalloc avatar Jul 23 '22 20:07 vimalloc

My first thought was to add the original error to the response message, but some of the errors may be too descriptive so I might not do that. Alternatively I would log the error message for troubleshooting. Without the original error you are kind of blind to what the issue is.

JustElectron avatar Jul 23 '22 21:07 JustElectron