-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: add embedder validation to prevent misleading status indicators (#4398) #5404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds validation of embedder configurations before indexing to prevent misleading "file watcher started" messages and ensure clear error reporting.
- Introduce
validateConfiguration()inIEmbedderand implement it for all embedder types. - Integrate validation in
CodeIndexServiceFactoryandCodeIndexManager, halting indexing on invalid config. - Expand i18n localization keys for validation errors and update webview handler to catch and rethrow validation failures.
Reviewed Changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/services/code-index/interfaces/embedder.ts | Added validateConfiguration() to the embedder API |
| src/services/code-index/service-factory.ts | New validateEmbedder() method |
| src/services/code-index/manager.ts | Validate embedder before indexing; error state logic |
| src/services/code-index/embedders/*.ts | Implemented validateConfiguration() in each embedder |
| src/core/webview/webviewMessageHandler.ts | Wrapped initialization call in try/catch for validation |
| src/i18n/locales/*/embeddings.json | Added generic validation keys for all locales |
Comments suppressed due to low confidence (3)
src/services/code-index/embedders/openai-compatible.ts:371
- The validation method returns the key
embeddings:validation.invalidResponse, but this key isn’t defined in the locale files. Please add aninvalidResponseentry undervalidationin allembeddings.jsonlocale files.
error: "embeddings:validation.invalidResponse",
src/services/code-index/embedders/openai.ts:207
- The code uses the translation key
embeddings:openai.invalidResponseFormat, but there’s no corresponding entry in the i18n locale files. Please add this key or adjust to an existing key so the message is localized correctly.
error: t("embeddings:openai.invalidResponseFormat"),
src/i18n/locales/en/embeddings.json:14
- The Ollama embedder code references
embeddings:errors.ollama.serviceNotRunning, but this key is declared directly underembeddingsrather than nested undererrors.ollama. Please align the key path in the locale file with the code reference.
"serviceNotRunning": "Ollama service is not running at {{baseUrl}}",
|
✅ No security or compliance issues detected. Reviewed everything up to 36e6f98. Security Overview
Detected Code ChangesThe diff is too large to display a summary of code changes. Reply to this PR with |
|
I was testing it by setting an invalid API key for the OpenAI provider, and it seems like the new settings aren't being saved. Instead of showing an error for the invalid key, the system appears to continue using my previous (valid) key. From what I can tell, the Ideally, the settings should be saved first, and then any errors should be shown during service initialization. That way, the user gets clear feedback about what’s wrong without losing their changes. |
dbaae88 to
464a3d2
Compare
|
Generated with ❤️ by ellipsis.dev |
|
Generated with ❤️ by ellipsis.dev |
- Fixed settings-save flow to save before validation - Fixed Error constructor usage in scanner.ts - Fixed segment identification in file-watcher.ts - Added missing translation keys for embedder validation errors
e89ea39 to
9419458
Compare
- Added missing ollama.title, description, and settings keys - Fixed translation check failure in CI/CD pipeline - Synchronized all 17 non-English locale files
- Validate embedder connection when switching providers - Prevent misleading 'Indexed' status when embedder is unavailable - Show immediate error feedback for invalid configurations - Add comprehensive test coverage for validation flow This ensures users get immediate feedback when configuring embedders, preventing confusion when providers like Ollama are not accessible.
- Created shared/validation-helpers.ts with centralized error handling utilities - Refactored OpenAI, OpenAI-Compatible, and Ollama embedders to use shared helpers - Eliminated duplicate error handling code across embedders - Improved maintainability and consistency of error handling - Fixed test compatibility in manager.spec.ts - All 2721 tests passing
… functions - Removed getErrorMessageForConnectionError and inlined logic into handleValidationError - Removed isRateLimitError, logRateLimitRetry, and logEmbeddingError wrapper functions - Updated openai.ts and openai-compatible.ts to inline rate limit checking and logging - Reduced code complexity while maintaining all functionality - All 311 tests continue to pass
- Added missing 'invalidResponse' key to all locale files - Fixed French translation: changed 'and accessible' to 'et accessible' - Ensures proper error messages are displayed when embedder returns invalid responses
| "invalidApiKey": "Неверный ключ API. Проверьте конфигурацию ключа API.", | ||
| "invalidBaseUrl": "Неверный базовый URL. Проверьте конфигурацию URL.", | ||
| "invalidModel": "Неверная модель. Проверьте конфигурацию модели.", | ||
| "invalidResponse": "Неверный ответ от службы embedder. Проверьте вашу конфигурацию." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typographical note: The new string uses "embedder" instead of the transliterated "эмбеддера" as used in the previous key ("Неверная конфигурация эмбеддера."). For consistency, consider using "эмбеддера" here as well.
| "invalidResponse": "Неверный ответ от службы embedder. Проверьте вашу конфигурацию." | |
| "invalidResponse": "Неверный ответ от службы эмбеддера. Проверьте вашу конфигурацию." |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
- Restored codebaseIndexSearchMaxResults and codebaseIndexSearchMinScore settings that were unintentionally removed - Keep embedder validation related changes
- Reverted point ID generation back to using line numbers instead of segmentHash
- Restored { cause: deleteError } parameter in scanner error handling
- These changes were unrelated to the embedder validation feature
daniel-lxs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Fixes #4398 - Code indexing was showing misleading status indicators when embedder configurations were invalid. Users would see both "standby" state and a green "file watcher started" message, suggesting the system was working when it was actually failing silently due to invalid embedder settings.
Closes: 5350
This PR adds proper validation during embedder instantiation to ensure configurations are valid before starting the indexing process. Users now receive immediate, actionable feedback about configuration issues.
Changes Made
Core Implementation
validateConfiguration()method toIEmbedderinterfaceCodeIndexServiceFactoryto validate embedder before returning instanceCodeIndexManagerto validate embedder before proceeding with indexingwebviewMessageHandlerReview Feedback Addressed
Based on PR review feedback, the following improvements were made:
i18n Consistency in Ollama Embedder
Timeout Handling with AbortController
Better Error Message Preservation
Testing
Test Coverage
Quality Checks
Translations
No new translations were required. All embedder validation error messages use existing translation keys in
src/i18n/locales/*/embeddings.jsonfiles that were already present and translated in all supported locales.Verification of Acceptance Criteria
✅ Invalid embedder configurations immediately show error state
✅ No "file watcher started" message appears for invalid configurations
✅ Clear, actionable error messages help users fix configuration
✅ System recovers gracefully when configuration is corrected
✅ All embedder types have appropriate validation
Checklist
Important
Adds embedder configuration validation to prevent misleading status indicators and improve error handling in the code indexing process.
validateConfiguration()toIEmbedderinterface for configuration validation.OpenAI,Ollama,OpenAI-compatible, andGeminiembedders.CodeIndexManagerto validate embedder before indexing.webviewMessageHandler.manager.tsandorchestrator.ts.service-factory.tsto preserve original error messages.manager.spec.ts,service-factory.spec.ts, and embedder test files.This description was created by
for 36e6f98. You can customize this summary. It will automatically update as commits are pushed.