Rake task fails for expired Personal Access Token
Problem to solve
While using Personal Access Tokens for rake tasks via console, the action errors out without providing a clear indication on why it failed.
Below is a snapshot that indicates in the logs the request is unauthorized:
It looks like the failure occurs while evaluating response.body
here in the website project.
- When the status code is not
200
, theabort_cache!([])
method is called. Note the method is called with the parameter[]
- The method throws an exception
:abort_cache
. - The exception handling block rewrites the cache with the
return_value
and also returns the return_value ([]) - The actual response return statement here is never reached in this case
User experience goal
Better visibility on the reason of failure.
Proposal
Return the response
in the exception block.
Links / references
Edited by Aishwarya Subramanian