Also move getting ado auth token into AdoCodeSearchService (#675)

Follow up on #673, doing the same for ado
This commit is contained in:
Matt Bierner
2025-08-19 14:23:58 -07:00
committed by GitHub
parent 9d2b6278f6
commit c257f79722
5 changed files with 62 additions and 88 deletions
@@ -84,7 +84,7 @@ export interface IGithubCodeSearchService {
triggerReason: 'auto' | 'manual' | 'tool',
githubRepoId: GithubRepoId,
telemetryInfo: TelemetryCorrelationId,
): Promise<boolean>;
): Promise<Result<true, RemoteCodeSearchError>>;
/**
* Semantic searches a given github repo for relevant code snippets
@@ -195,10 +195,10 @@ export class GithubCodeSearchService implements IGithubCodeSearchService {
triggerReason: 'auto' | 'manual' | 'tool',
githubRepoId: GithubRepoId,
telemetryInfo: TelemetryCorrelationId,
): Promise<boolean> {
): Promise<Result<true, RemoteCodeSearchError>> {
const authToken = await this.getGithubAccessToken(auth.silent);
if (!authToken) {
return false;
return Result.error({ type: 'not-authorized' });
}
const response = await this._capiClientService.makeRequest<Response>({
@@ -232,7 +232,7 @@ export class GithubCodeSearchService implements IGithubCodeSearchService {
statusCode: response.status,
});
return false;
return Result.error({ type: 'generic-error', error: new Error(`Failed to request indexing for '${githubRepoId}'. Response: ${response.status}.`) });
}
/* __GDPR__
@@ -250,7 +250,7 @@ export class GithubCodeSearchService implements IGithubCodeSearchService {
triggerReason,
}, {});
return true;
return Result.ok(true);
}
async searchRepo(