Skip to content

Commit

Permalink
Do not handle 401/auth errors in router (#4000)
Browse files Browse the repository at this point in the history
Fixes #3999.

This is related to #3948 in which I fixed the infinite request loop in case requests to the metadata API fail. This works as intended, but has one unintended side effect: We were actually kind of relying on the previous behavior to handle expired session tokens.

For context: When a user logs in, the session token is stored. When the session token expires, future API requests using that session token will obviously fail. The UI was previously handling 401 response codes to invalidate the stored session token and display a login popup or redirect to the OAuth service.

The change introduced in #3948 also prevented the handling of requests that failed to expired session tokens. I’m not convinced that this way of handling expired session tokens is a good solution as it’s pretty opaque.

So with this change, we will keep the newly introduced behavior (which shows an error message and a "Retry" button) in case a request to the metadata API fails, *except* if it failed with a 401 response in which case we still do whatever happened before.
  • Loading branch information
tillprochaska authored Nov 19, 2024
1 parent 3cffdd2 commit 6a28fcf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ui/src/app/Router.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ class Router extends Component {
fetchIfNeeded() {
const { metadata, messages } = this.props;

if (metadata.shouldLoad && !metadata.isError) {
if (
metadata.shouldLoad &&
(!metadata.isError || metadata.error?.response?.status === 401)
) {
this.props.fetchMetadata();
}

Expand Down

0 comments on commit 6a28fcf

Please sign in to comment.