Skip to content

Commit df0b181

Browse files
committed
fix: simplify error handling in manager.ts and update tests to expect translation keys
- Remove complex fallback logic from manager.ts since errors should be translated at source - Update tests to expect translation keys as returned by t() function in test environment - This ensures consistent behavior between test and production environments
1 parent 6c5b36d commit df0b181

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ describe("CodeIndexManager - handleSettingsChange regression", () => {
308308
})
309309

310310
// Act & Assert
311+
// In test environment, t() returns the key
311312
await expect((manager as any)._recreateServices()).rejects.toThrow(
312313
"embeddings:validation.authenticationFailed",
313314
)
@@ -331,6 +332,7 @@ describe("CodeIndexManager - handleSettingsChange regression", () => {
331332
})
332333

333334
// Act & Assert
335+
// In test environment, t() returns the key
334336
await expect((manager as any)._recreateServices()).rejects.toThrow(
335337
"embeddings:validation.configurationError",
336338
)

src/services/code-index/manager.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,8 @@ export class CodeIndexManager {
263263
const validationResult = await this._serviceFactory.validateEmbedder(embedder)
264264
if (!validationResult.valid) {
265265
const errorMessage = validationResult.error || "Embedder configuration validation failed"
266-
// Always attempt translation, use original as fallback
267-
const translatedMessage = t(errorMessage)
268-
269-
// If i18next returns the key, it means no translation was found.
270-
// In that case, we should use the original, untranslated error message.
271-
const finalMessage = translatedMessage === errorMessage ? errorMessage : translatedMessage
272-
273-
this._stateManager.setSystemState("Error", finalMessage)
274-
throw new Error(finalMessage)
266+
this._stateManager.setSystemState("Error", errorMessage)
267+
throw new Error(errorMessage)
275268
}
276269

277270
// (Re)Initialize orchestrator

0 commit comments

Comments
 (0)