feat(ai): OpenAI retry parity — typed error + tests (closes #69)#99
feat(ai): OpenAI retry parity — typed error + tests (closes #69)#99gh-simili-bot merged 2 commits intomainfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…retry parity - Introduce *openAIStatusError in retry.go so isRetryableError recognises OpenAI 429/5xx responses and retries them (previously unretried) - Add baseURL param to callOpenAIJSON (empty = production openAIBaseURL) - Add unexported baseURL field to Embedder and LLMClient for test injection Signed-off-by: Kavirubc <hapuarachchikaviru@gmail.com>
8 httptest-based tests covering 429/5xx retry, non-retryable 400, and retry exhaustion for both embedOpenAI and generateOpenAIText. Signed-off-by: Kavirubc <hapuarachchikaviru@gmail.com>
3156ea6 to
8ec0698
Compare
Simili Triage ReportNote Quality Score: 9.5/10 (Excellent) Classification
Quality Improvements
Similar Threads
Warning Possible Duplicate (Confidence: 98%) ⏳ This pull request will be automatically closed in 72 hours if no objections are raised. If you believe this is not a duplicate, please leave a comment explaining why. Generated by Simili Bot |
🧪 E2E Test✅ Bot responded: yes | Auto-closer (dry-run) | processed: 0 closed: 0 grace: 0 human: 0 | Test repo → gh-simili-bot/simili-e2e-22707564014 Auto-generated by E2E pipeline |
Summary
isRetryableErrorpreviously never retried OpenAI calls because errors fromcallOpenAIJSONwere plainfmt.Errorfstrings with no typed carrier. Introduced*openAIStatusError(carries HTTP status code) soerrors.Ascan detect 429/5xx and retry them identically to Gemini.baseURL stringfield to bothEmbedderandLLMClient(empty = production) and a matching parameter tocallOpenAIJSON, allowing tests to inject anhttptest.ServerURL without any mocking framework.openai_retry_test.gocovering retry-on-429, retry-on-500, no-retry-on-400, and retry exhaustion for bothembedOpenAIandgenerateOpenAIText.Files changed
internal/integrations/ai/retry.goopenAIStatusError; updateisRetryableErrorinternal/integrations/ai/provider.go*openAIStatusError; addbaseURLparam tocallOpenAIJSONinternal/integrations/ai/embedder.gobaseURLfield; pass tocallOpenAIJSONinternal/integrations/ai/llm.gobaseURLfield; pass tocallOpenAIJSONinternal/integrations/ai/openai_retry_test.goTest plan
go test ./internal/integrations/ai/... -run TestEmbedOpenAI -v— all 4 passgo test ./internal/integrations/ai/... -run TestGenerateOpenAIText -v— all 4 passgo test ./...— full suite passes (12/12 packages)go build ./...— no compilation errorsgo vet ./...— no issues