-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Description
1. Silence of the Launchpad
Steps to reproduce
on GitLens v17.3.0
- Connect GitHub and GitLab on GKDev
- Sync integrations in GitLens
- Go to GitLab OAuth settings (or Azure) and reject the application (keep it connected on GKDev)
- for GitLab it stops working immediately, for Azure wait for 30min until the azure token expires
- Open the launchpad
Expected result
You see GitHub PRs
Actual result
You fail seeing any PRs, because of GitLab error:
Related issues:
Technical details
It feels like it's here:
vscode-gitlens/src/plus/integrations/integrationService.ts
Lines 716 to 756 in 6dfa541
| private async getMyPullRequestsCore( | |
| integrations: Map<GitHostIntegration, ResourceDescriptor[] | undefined>, | |
| cancellation?: CancellationToken, | |
| silent?: boolean, | |
| ): Promise<IntegrationResult<PullRequest[] | undefined>> { | |
| const start = Date.now(); | |
| const promises: Promise<IntegrationResult<PullRequest[] | undefined>>[] = []; | |
| for (const [integration, repos] of integrations) { | |
| if (integration == null) continue; | |
| promises.push(integration.searchMyPullRequests(repos, cancellation, silent)); | |
| } | |
| const results = await Promise.allSettled(promises); | |
| const errors = [ | |
| ...filterMap(results, r => | |
| r.status === 'fulfilled' && r.value?.error != null ? r.value.error : undefined, | |
| ), | |
| ]; | |
| if (errors.length) { | |
| return { | |
| error: errors.length === 1 ? errors[0] : new AggregateError(errors), | |
| duration: Date.now() - start, | |
| }; | |
| } | |
| return { | |
| value: [ | |
| ...flatten( | |
| filterMap(results, r => | |
| r.status === 'fulfilled' && r.value != null && r.value?.error == null | |
| ? r.value.value | |
| : undefined, | |
| ), | |
| ), | |
| ], | |
| duration: Date.now() - start, | |
| }; | |
| } |
Maybe we should not fail the whole procedure if one of integrations fails?
2. swallowing of an Authentication Error
...
Follow-ups
Cache
Cached errors:
- connect GitHub on GKDev
- sync accounts on GitLens
- revoke the authorization on GitHub
- reload window -> you get Auth error cached
- go to GKDev and reconnect GitHub
- refresh integrations in GitLens
- the cached Auth error does not disappear
Even better:
IntegrationAuthenticationService does not react to gitlens.cloudIntegrations.enabled change
- turn
"gitlens.cloudIntegrations.enabled"tofalse - reload window: The app starts using Local providers
- turn
"gitlens.cloudIntegrations.enabled"totrue ⚠️ without reloadin the window the app keeps using Local providers
declining invalid GitHub tokens
We can understand about many tokens that they are invalid because they are outdated (token.expiresAt is in the past), but GitHub tokens are not provided with expiration date, therefore we do not decline them by reason of expiration.
GKDev web page sends https://api.github.com/graphql: {"query":"query { rateLimit(dryRun: true) { __typename } }"} and by response they can show on the web-page that it's invalid:
{
"message": "Bad credentials",
"documentation_url": "https://docs.github.com/rest",
"status": "401"
}
Our options are:
- leave it on GitLens as is
- query GitHub for token validity in the same way as it's done on the web page.
- Convince GKDev to retire invalid GitHub token on their side and do not send them to us, or at least let us know that they are invalid.
- Nuke the invalid token from GKDev. we can do following:
- detect that the GitHub token is invalid
- try to refresh with GKDev, if it succeeds—good, if it fails—go further. (maybe we can skip this step because probably it always fails)
- kick the token away from GKDev
- open a piece of UI that would let user to reconnect GitHub.