Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an explicit “validate current Git credentials” flow to better detect revoked/invalid OAuth tokens (notably for GitHub where anonymous git access can still succeed on public repos), and wires that validation into the project settings UI and Electron IPC.
Changes:
- Add an optional
validateCredentials()capability to git remote providers and implement it for GitHub and GitLab viaGET /user. - Add a new
/git/validate-credentialsclient loader route + fetcher hook, backed by a newgit.validateGitRepositoryCredentialsIPC endpoint in the main process. - Update the project settings form to call the validation fetcher and use its errors to drive the OAuth re-auth banner / hide author email selection when auth errors are present.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/insomnia/src/ui/components/project/project-settings-form.tsx | Switches from loading repo data to calling the new credential-validation fetcher and uses returned errors in the Git auth banner UI. |
| packages/insomnia/src/sync/git/providers/types.ts | Extends the provider interface with optional validateCredentials(). |
| packages/insomnia/src/sync/git/providers/gitlab.ts | Implements credential validation against GitLab’s GET /user. |
| packages/insomnia/src/sync/git/providers/github.ts | Implements credential validation against GitHub’s GET /user. |
| packages/insomnia/src/routes/git.validate-credentials.tsx | Adds a new route + fetcher hook for validating credentials from the renderer. |
| packages/insomnia/src/main/ipc/electron.ts | Adds a new IPC channel type for credential validation. |
| packages/insomnia/src/main/git-service.ts | Adds the main-process validation implementation and registers the IPC handler; also validates credentials during loadGitRepository init. |
| packages/insomnia/src/entry.preload.ts | Exposes the new validation API on window.main.git. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/insomnia/src/ui/components/project/project-settings-form.tsx
Outdated
Show resolved
Hide resolved
packages/insomnia/src/ui/components/project/project-settings-form.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| provider={selectedProvider} | ||
| /> | ||
| {showEmailSelector ? ( | ||
| {showEmailSelector && !credentialsValidationErrors ? ( |
There was a problem hiding this comment.
!credentialsValidationErrors treats empty arrays as errors, so successful validation with [] hides the email UI paths unexpectedly.
Details
✨ AI Reasoning
The new credential-validation checks use boolean negation on an errors collection instead of checking whether it contains entries. When validation succeeds and returns an empty list, the condition still evaluates as if an error exists, so the branch that should show author email data is skipped. This creates a deterministic mismatch between successful validation and UI behavior.
🔧 How do I fix it?
Trace execution paths carefully. Ensure precondition checks happen before using values, validate ranges before checking impossible conditions, and don't check for states that the code has already ruled out.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
Summary
validateCredentialsmethod to the GitHub and GitLab provider implementations that hits the provider'sGET /userREST API endpoint — a lightweight, authoritative check that reliably returns HTTP 401 for revoked tokens or uninstalled GitHub Apps (unlike the git wire protocol, which can succeed anonymously on public repos).validateCredentialsmethod to theGitRemoteProviderinterface, with a fallback tofetchRemoteBranchesfor providers that don't implement it.validateGitRepositoryCredentialsIPC handler ingit-service.tsthat looks up the stored credential for a project/workspace and delegates to the appropriate validation strategy.git.validate-credentialsroute and auseGitValidateCredentialsFetcherhook so the UI can trigger credential validation on demand.loadGitRepository(afterGitVCS.init()) to surface revoked tokens as HTTP 4xx errors, which triggers the existing re-auth banner logic.Test plan