Fix GithubCodeSearchService.triggerIndexing 401 auth error handling#319965
Merged
Conversation
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
changed the title
[WIP] Fix GithubCodeSearchService trigger indexing error
Fix GithubCodeSearchService.triggerIndexing 401 auth error handling
Jun 4, 2026
mjbvz
approved these changes
Jun 4, 2026
mjbvz
approved these changes
Jun 4, 2026
Contributor
There was a problem hiding this comment.
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.triggerRemoteIndexingOfRepoto correctly detectResultfailures (isError()vs a truthy check). - Update
GithubCodeSearchServiceto classify 401/403 responses as{ type: 'not-authorized' }in bothgetRemoteIndexStateandtriggerIndexing.
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
triggerIndexingcan now return{ type: 'not-authorized' }(401/403), but this error path currently updates the repo state toNotYetIndexedand returns a genericrequest-to-index-failederror. This means the UI will keep offering “Index?” instead of the “Sign in?” /NotAuthorizedstate, andtryAuthIfNeededwon’t kick in because it only looks forCodeSearchRepoStatus.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
rzhao271
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.triggerSuccessis aResultobject (always truthy). On error, the code falls through to setBuildingIndexstate and returnResult.ok(true), so the UI shows an infinite spinner. Fixed totriggerSuccess.isError().githubCodeSearchService.ts: 401/403 responses misclassified asgeneric-error. BothtriggerIndexingandgetRemoteIndexStatereturned{ 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 correctNotAuthorizedUI state instead ofCouldNotCheckIndexStatus.