-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: prevent indexer hanging on OpenAI insufficient quota errors (#5350) #5351
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
|
✅ No security or compliance issues detected. Reviewed everything up to 3905dcb. Security Overview
Detected Code Changes
Reply to this PR with |
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
This PR prevents the code indexer from hanging on OpenAI quota errors by detecting insufficient-quota errors and failing immediately, while preserving existing retry behavior for rate limits.
- Added
isInsufficientQuotaErrorto both embedders and updated retry logic to throw on quota errors - Introduced user-friendly localized error messages and tests for quota vs. rate-limit behavior
- Enhanced diff view to preserve editor focus and updated tooling calls to await the async scroll method
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/services/code-index/embedders/openai.ts | Detect quota errors and skip retries in _embedBatchWithRetries |
| src/services/code-index/embedders/openai-compatible.ts | Same quota-detection patch for the compatible embedder |
| src/services/code-index/embedders/tests/openai.spec.ts | Added tests for insufficient-quota and rate-limit scenarios |
| src/services/code-index/embedders/tests/openai-compatible.spec.ts | Added analogous tests |
| src/integrations/editor/DiffViewProvider.ts | Added preserveFocus and focus-restoration logic, made scroll async |
| src/integrations/editor/tests/DiffViewProvider.spec.ts | Updated tests to expect preserveFocus: true |
| src/core/tools/writeToFileTool.ts | Awaited the newly async scrollToFirstDiff call |
| src/core/tools/searchAndReplaceTool.ts | Awaited the newly async scrollToFirstDiff call |
| src/core/tools/insertContentTool.ts | Awaited the newly async scrollToFirstDiff call |
| src/i18n/locales/*/embeddings.json | Added insufficientQuota translation in all supported languages |
|
It looks like the changes for focus preservation have been included in this pull request. Since there is a separate PR for that work, could you please remove the unrelated focus-preservation changes from this one to keep it focused on the OpenAI quota issue? |
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.
Consider checking error.response?.status in addition to error.status to robustly detect 429 errors when the status code is nested under response.
| if (error?.status !== 429) return false | |
| if (error?.status !== 429 && error?.response?.status !== 429) return false |
6e28440 to
3905dcb
Compare
|
Closed in favour of #5404 |
Description
This PR fixes an issue where the code indexer would hang indefinitely when using OpenAI embeddings with an account that has insufficient credits/quota. Previously, all HTTP 429 errors were treated as retryable rate-limit errors, causing the indexer to retry endlessly even when the error was due to insufficient funds.
Changes Made
1. Enhanced Error Detection
isInsufficientQuotaError()method to both OpenAI embedders to detect quota-related 429 errors2. Modified Retry Logic
_embedBatchWithRetries()in bothopenai.tsandopenai-compatible.ts3. User-Friendly Error Messages
4. Comprehensive Test Coverage
Testing
Unit Tests
Code Quality
Verification
Acceptance Criteria Met:
Manual Testing Recommended:
Notes
Fixes #5350
Important
Fixes indexer hanging by detecting and handling OpenAI insufficient quota errors without retrying, with enhanced user feedback and test coverage.
isInsufficientQuotaError()inquota-detection.tsto identify quota-related 429 errors._embedBatchWithRetries()inopenai.tsandopenai-compatible.tsto throw on quota errors without retrying.openai.spec.tsandopenai-compatible.spec.tsto verify immediate failure on quota errors and retry logic for rate limits.This description was created by
for 3905dcb. You can customize this summary. It will automatically update as commits are pushed.