Skip to content

Commit 3859e5d

Browse files
authored
fix(code-index): remove automatic startup embedder validation (#1879)
* fix(code-index): make startup embedder validation non-blocking * test(code-index): update scope constructor expectations for readiness manager * test(code-index): include readiness dependency in search workspace assertion * test(code-index): cover stale validation rejections and strengthen service assertions * test(code-index): cover readiness validation fallback errors * fix(code-index): remove automatic embedder preflight validation * fix(code-index): report incremental scan errors without clearing existing index * fix(code-index): preserve existing index across failed retries * test(code-index): cover cleanup after partial full-scan progress * fix(code-index): exclude private error details from indexing telemetry
1 parent 51181e8 commit 3859e5d

7 files changed

Lines changed: 246 additions & 130 deletions

File tree

‎src/eslint-suppressions.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,12 +1301,12 @@
13011301
},
13021302
"services/code-index/__tests__/manager.spec.ts": {
13031303
"@typescript-eslint/no-explicit-any": {
1304-
"count": 87
1304+
"count": 84
13051305
}
13061306
},
13071307
"services/code-index/__tests__/orchestrator.spec.ts": {
13081308
"@typescript-eslint/no-explicit-any": {
1309-
"count": 25
1309+
"count": 23
13101310
}
13111311
},
13121312
"services/code-index/__tests__/service-factory.spec.ts": {

‎src/services/code-index/__tests__/code-index-scan-executor.spec.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,23 @@ describe("CodeIndexScanExecutor", () => {
136136
},
137137
)
138138

139-
it.each([0, 2])("preserves incremental batch-error tolerance with %s indexed blocks", async (indexed) => {
139+
it.each([0, 2])("rejects incremental batch errors with %s indexed blocks", async (indexed) => {
140140
const { executor, scanner } = setup()
141+
const failures = [new Error("embedding failure"), new Error("upsert failure"), new Error("embedding failure")]
141142
scanner.scanDirectory.mockImplementation(async (_path, onError, onIndexed, onParsed) => {
142143
onParsed?.(3)
143144
onIndexed?.(indexed)
144-
onError?.(new Error("batch failure"))
145+
for (const failure of failures) onError?.(failure)
145146
return { stats: { processed: 1, skipped: 0 }, totalBlockCount: 3 }
146147
})
147-
await expect(executor.runIncrementalScan(new AbortController().signal)).resolves.toBe(true)
148+
const result = executor.runIncrementalScan(new AbortController().signal)
149+
await expect(result).rejects.toBeInstanceOf(AggregateError)
150+
await expect(result).rejects.toMatchObject({
151+
errors: failures,
152+
message: "Incremental scan failed with 3 errors:\nembedding failure\nupsert failure",
153+
})
154+
await result.catch((error: AggregateError) => {
155+
for (const [index, failure] of failures.entries()) expect(error.errors[index]).toBe(failure)
156+
})
148157
})
149158
})

‎src/services/code-index/__tests__/manager.spec.ts‎

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { makeExtensionContext } from "../../../test-utils/vscode"
33
import { CodeIndexManager } from "../manager"
44
import { CodeIndexManagerRegistry } from "../code-index-manager-registry"
55
import { CodeIndexServiceFactory } from "../service-factory"
6+
import { CodeIndexOrchestrator } from "../orchestrator"
7+
import { CodeIndexSearchService } from "../search-service"
68
import type { MockedClass } from "vitest"
79
import * as path from "path"
810
import { providerIdentifiers } from "@roo-code/types/provider-identifiers"
@@ -474,63 +476,19 @@ describe("CodeIndexManager - handleSettingsChange regression", () => {
474476
;(manager as any)._configManager = mockConfigManager
475477
})
476478

477-
it("should validate embedder during _recreateServices when validation succeeds", async () => {
478-
// Arrange
479-
mockServiceFactoryInstance.validateEmbedder.mockResolvedValue({ valid: true })
480-
481-
// Act - directly call the private method for testing
482-
await (manager as any)._recreateServices()
483-
484-
// Assert
485-
expect(mockServiceFactoryInstance.createServices).toHaveBeenCalled()
486-
const createdEmbedder = mockServiceFactoryInstance.createServices.mock.results[0].value.embedder
487-
expect(mockServiceFactoryInstance.validateEmbedder).toHaveBeenCalledWith(createdEmbedder)
488-
expect(mockStateManager.setSystemState).not.toHaveBeenCalledWith("Error", expect.any(String))
489-
})
490-
491-
it("should set error state when embedder validation fails", async () => {
492-
// Arrange
479+
it("should create indexing services without a startup embedder validation request", async () => {
493480
mockServiceFactoryInstance.validateEmbedder.mockResolvedValue({
494481
valid: false,
495-
error: "embeddings:validation.authenticationFailed",
482+
error: "Embedder unavailable",
496483
})
497484

498-
// Act & Assert
499-
await expect((manager as any)._recreateServices()).rejects.toThrow(
500-
"embeddings:validation.authenticationFailed",
501-
)
485+
await manager["_recreateServices"]()
502486

503-
// Assert other expectations
504487
expect(mockServiceFactoryInstance.createServices).toHaveBeenCalled()
505-
const createdEmbedder = mockServiceFactoryInstance.createServices.mock.results[0].value.embedder
506-
expect(mockServiceFactoryInstance.validateEmbedder).toHaveBeenCalledWith(createdEmbedder)
507-
expect(mockStateManager.setSystemState).toHaveBeenCalledWith(
508-
"Error",
509-
"embeddings:validation.authenticationFailed",
510-
)
511-
})
512-
513-
it("should set generic error state when embedder validation throws", async () => {
514-
// Arrange
515-
// Since the real service factory catches exceptions, we should mock it to resolve with an error
516-
mockServiceFactoryInstance.validateEmbedder.mockResolvedValue({
517-
valid: false,
518-
error: "embeddings:validation.configurationError",
519-
})
520-
521-
// Act & Assert
522-
await expect((manager as any)._recreateServices()).rejects.toThrow(
523-
"embeddings:validation.configurationError",
524-
)
525-
526-
// Assert other expectations
527-
expect(mockServiceFactoryInstance.createServices).toHaveBeenCalled()
528-
const createdEmbedder = mockServiceFactoryInstance.createServices.mock.results[0].value.embedder
529-
expect(mockServiceFactoryInstance.validateEmbedder).toHaveBeenCalledWith(createdEmbedder)
530-
expect(mockStateManager.setSystemState).toHaveBeenCalledWith(
531-
"Error",
532-
"embeddings:validation.configurationError",
533-
)
488+
expect(mockServiceFactoryInstance.validateEmbedder).not.toHaveBeenCalled()
489+
expect(mockStateManager.setSystemState).not.toHaveBeenCalledWith("Error", expect.any(String))
490+
expect(manager["_orchestrator"]).toBeInstanceOf(CodeIndexOrchestrator)
491+
expect(manager["_searchService"]).toBeInstanceOf(CodeIndexSearchService)
534492
})
535493

536494
it("should handle embedder creation failure", async () => {
@@ -684,7 +642,7 @@ describe("CodeIndexManager - handleSettingsChange regression", () => {
684642
// Assert - manager should be initialized again
685643
expect(manager.isInitialized).toBe(true)
686644
expect(mockServiceFactoryInstance.createServices).toHaveBeenCalled()
687-
expect(mockServiceFactoryInstance.validateEmbedder).toHaveBeenCalled()
645+
expect(mockServiceFactoryInstance.validateEmbedder).not.toHaveBeenCalled()
688646
})
689647

690648
it("should be safe to call when not in error state (idempotent)", async () => {

0 commit comments

Comments
 (0)