refactor: remove deprecated openai-error-handler shim and use error-handler#767
Conversation
… error-handler Replace all imports of the deprecated `openai-error-handler` shim with `error-handler`, which has been the canonical source since #10204. Delete `openai-error-handler.ts` and its duplicate test file, as `error-handler.spec.ts` already covers the same behavior. Signed-off-by: daewoongoh <dw.oh@samsung.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughRemoves the deprecated ChangesShim removal and import consolidation
Estimated code review effort: 1 (Trivial) | ~3 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Cover the catch block that wraps API errors via handleOpenAIError, fixing 0% patch coverage on the error path. Signed-off-by: daewoongoh <dw.oh@samsung.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
edelauna
left a comment
There was a problem hiding this comment.
Looks good - had some comments around test accuracy and import consistency.
| ) | ||
| } catch (error) { | ||
| const { handleOpenAIError } = await import("./utils/openai-error-handler") | ||
| const { handleOpenAIError } = await import("./utils/error-handler") |
There was a problem hiding this comment.
Every other provider uses a static import for handleOpenAIError at the top of the file — is there a reason this one uses a dynamic import inside the catch block? If not, a static import would keep it consistent.
| const { handleOpenAIError } = await import("./utils/error-handler") | |
| import { handleOpenAIError } from "./utils/error-handler" |
(And the catch body becomes just throw handleOpenAIError(error, "DeepSeek"))
There was a problem hiding this comment.
There wasn’t a specific reason to keep this as a dynamic import.
I’ve updated DeepSeek to use the same static handleOpenAIError import as the other providers and simplified the catch block to call throw handleOpenAIError(error, "DeepSeek") directly.
| mockCreate.mockRejectedValueOnce(apiError) | ||
|
|
||
| const stream = handler.createMessage(systemPrompt, messages) | ||
| await expect(stream.next()).rejects.toThrow("DeepSeek completion error: Invalid API key") |
There was a problem hiding this comment.
The test checks the message format, but .status is what the retry/backoff logic reads downstream — could we assert that it is preserved too?
| await expect(stream.next()).rejects.toThrow("DeepSeek completion error: Invalid API key") | |
| const err = await stream.next().catch((e) => e) | |
| expect(err.message).toBe("DeepSeek completion error: Invalid API key") | |
| expect((err as any).status).toBe(401) |
There was a problem hiding this comment.
I’ve updated the DeepSeek error test to capture the thrown error and assert both the wrapped message and the preserved status value.
This should cover the downstream retry/backoff logic that reads .status.
…Error Replace dynamic `await import()` with a static import for `handleOpenAIError` in the catch block, and update the error handler test to also assert the HTTP status code (401) on the thrown error. Signed-off-by: daewoongoh <dw.oh@samsung.com>
Related GitHub Issue
Closes: #766
Description
This PR removes the deprecated
openai-error-handlercompatibility shim and consolidates all related imports to use the canonicalerror-handlerutility directly.error-handlerhas been the canonical source for OpenAI-compatible error handling since RooCodeInc/Roo-Code#10204. The deprecatedopenai-error-handlermodule only acted as a shim, so keeping it added unnecessary duplication and maintenance overhead.Key changes:
openai-error-handlershim witherror-handler.src/api/providers/utils/openai-error-handler.ts.openai-error-handler.spec.tstest file.error-handler.ts.error-handler.spec.ts, which already covers the same behavior previously tested by the removed duplicate test.This PR is intended to be a no-behavior-change refactor. It simplifies the provider utility structure while preserving the existing
handleOpenAIErrorbehavior.Test Procedure
pnpm check-types pnpm testPre-Submission Checklist
Screenshots / Videos
N/A
Documentation Updates
Get in Touch
hehegwk_23849
Summary by CodeRabbit