Handle 401 errors in the Web IDE more gracefully
Problem to solve
In some instances, an authenticated session will expire while the Web IDE Beta is opened. This causes the file system to fall out of date with the current state and prevents you from committing changes. The current error messages don't give any indication that you have to re-authenticate and there's no mechanism by which to re-authenticate from within the Web IDE UI.
This seems to be a particular issue with our internal GitLab SAML timeout, as aggressive as it is. But it also makes it harder to troubleshoot and reproduce. What I've seen is this:
- Have an authenticated session in GitLab.com, maybe editing a project under
gitlab-org
- Wait a while, the session expires but the GitLab UI doesn't refresh or indicate that re-authentication is necessary
- Open the Web IDE
- Observe the current state of the file system is not accurate
- Make an edit
- Attempt to commit
- Observe error message and commit never goes through
- Open gitlab.com in another tab
- Navigate to the project
- Get prompted to re-authenticate with SAML
- Refresh the Web IDE, boom, state is accurate.
Proposal
Handle authentication errors more gracefully in the Web IDE. If the current session has expired, re-direct to the SAML flow instead of showing a stale version of the file system or allowing edits to be made that can't be committed.