Skip to content

Fix GithubCodeSearchService.triggerIndexing 401 auth error handling#319965

Merged
mjbvz merged 2 commits into
mainfrom
copilot/fix-repo-indexing-issue
Jun 4, 2026
Merged

Fix GithubCodeSearchService.triggerIndexing 401 auth error handling#319965
mjbvz merged 2 commits into
mainfrom
copilot/fix-repo-indexing-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 4, 2026

Fixes #318023

When the GitHub code search indexing API returns a 401, the Codebase Semantic Index spinner runs forever and never recovers—even across restarts.

Two bugs:

  • codeSearchRepo.ts: if (!triggerSuccess) is always false. triggerSuccess is a Result object (always truthy). On error, the code falls through to set BuildingIndex state and return Result.ok(true), so the UI shows an infinite spinner. Fixed to triggerSuccess.isError().

  • githubCodeSearchService.ts: 401/403 responses misclassified as generic-error. Both triggerIndexing and getRemoteIndexState returned { type: 'generic-error' } for all non-OK responses. The ADO equivalent already distinguishes 401/403 → { type: 'not-authorized' }. Added the same check so callers can map to the correct NotAuthorized UI state instead of CouldNotCheckIndexStatus.

Copilot AI self-assigned this Jun 4, 2026
Copilot AI review requested due to automatic review settings June 4, 2026 17:26
Copilot AI review requested due to automatic review settings June 4, 2026 17:26
Fix two bugs causing the Codebase Semantic Index to show a perpetual
"Indexing..." spinner when the API returns a 401 authentication error:

1. Fix `codeSearchRepo.ts`: Change `if (!triggerSuccess)` to
   `if (triggerSuccess.isError())`. The Result object is always truthy,
   so the error handling code was never executed — errors fell through
   to set BuildingIndex state and return ok.

2. Fix `githubCodeSearchService.ts`: Return `{ type: 'not-authorized' }`
   for 401/403 HTTP responses in both `triggerIndexing` and
   `getRemoteIndexState`, matching the pattern in `adoCodeSearchService.ts`.
   This allows callers to properly differentiate auth failures.

Co-authored-by: mjbvz <12821956+mjbvz@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot June 4, 2026 17:41
Copilot AI changed the title [WIP] Fix GithubCodeSearchService trigger indexing error Fix GithubCodeSearchService.triggerIndexing 401 auth error handling Jun 4, 2026
Copilot finished work on behalf of mjbvz June 4, 2026 17:42
Copilot AI requested a review from mjbvz June 4, 2026 17:42
@mjbvz mjbvz marked this pull request as ready for review June 4, 2026 21:19
Copilot AI review requested due to automatic review settings June 4, 2026 21:19
@mjbvz mjbvz enabled auto-merge June 4, 2026 21:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Codebase Semantic Index getting stuck in an “Indexing…” spinner when GitHub’s indexing endpoints return 401/403, by correctly detecting trigger failures and classifying authorization errors so the UI can reflect an unauthenticated/unauthorized state.

Changes:

  • Fix GithubCodeSearchRepo.triggerRemoteIndexingOfRepo to correctly detect Result failures (isError() vs a truthy check).
  • Update GithubCodeSearchService to classify 401/403 responses as { type: 'not-authorized' } in both getRemoteIndexState and triggerIndexing.
Show a summary per file
File Description
extensions/copilot/src/platform/workspaceChunkSearch/node/codeSearch/codeSearchRepo.ts Fixes incorrect success detection when triggering remote indexing, preventing false “building” state.
extensions/copilot/src/platform/remoteCodeSearch/common/githubCodeSearchService.ts Differentiates 401/403 from generic failures so callers can surface a NotAuthorized UI state.

Copilot's findings

Comments suppressed due to low confidence (1)

extensions/copilot/src/platform/workspaceChunkSearch/node/codeSearch/codeSearchRepo.ts:417

  • triggerIndexing can now return { type: 'not-authorized' } (401/403), but this error path currently updates the repo state to NotYetIndexed and returns a generic request-to-index-failed error. This means the UI will keep offering “Index?” instead of the “Sign in?” / NotAuthorized state, and tryAuthIfNeeded won’t kick in because it only looks for CodeSearchRepoStatus.NotAuthorized.
		const triggerSuccess = await this._githubCodeSearchService.triggerIndexing({ silent: true }, triggerReason, this._githubRepoId, telemetryInfo);
		if (triggerSuccess.isError()) {
			this._logService.error(`RepoTracker::TriggerRemoteIndexing(${triggerReason}). Failed to request indexing for '${this.remoteInfo.repoId}'.`);

			this.updateState({ status: CodeSearchRepoStatus.NotYetIndexed });

			return Result.error(TriggerRemoteIndexingError.errorTriggeringIndexing(this.remoteInfo.repoId));
  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@mjbvz mjbvz merged commit 9c4ea49 into main Jun 4, 2026
26 checks passed
@mjbvz mjbvz deleted the copilot/fix-repo-indexing-issue branch June 4, 2026 22:07
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GithubCodeSearchService.triggerIndexing Failed to request indexing for repo

4 participants