From 385e952935d9f63353ea3ddf540233f87f3065db Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:05:16 -0700 Subject: [PATCH] fix: OpenRouter showing cline credits error after 402 response (#5590) * fix: OpenRouter showing cline credits error after 402 response * Create silly-scissors-repair.md --- .changeset/silly-scissors-repair.md | 5 +++++ src/services/error/ClineError.ts | 2 +- webview-ui/src/components/chat/ErrorRow.tsx | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/silly-scissors-repair.md diff --git a/.changeset/silly-scissors-repair.md b/.changeset/silly-scissors-repair.md new file mode 100644 index 00000000..b7834975 --- /dev/null +++ b/.changeset/silly-scissors-repair.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +fix: OpenRouter showing cline credits error after 402 response diff --git a/src/services/error/ClineError.ts b/src/services/error/ClineError.ts index f627abc3..aa010cb4 100644 --- a/src/services/error/ClineError.ts +++ b/src/services/error/ClineError.ts @@ -129,7 +129,7 @@ export class ClineError extends Error { const { code, status, details } = err._error // Check balance error first (most specific) - if (status === 402 || (code === "insufficient_credits" && typeof details?.current_balance === "number")) { + if (code === "insufficient_credits" && typeof details?.current_balance === "number") { return ClineErrorType.Balance } diff --git a/webview-ui/src/components/chat/ErrorRow.tsx b/webview-ui/src/components/chat/ErrorRow.tsx index 1fa8564e..24d59d8f 100644 --- a/webview-ui/src/components/chat/ErrorRow.tsx +++ b/webview-ui/src/components/chat/ErrorRow.tsx @@ -24,10 +24,11 @@ const ErrorRow = memo(({ message, errorType, apiRequestFailedMessage, apiReqStre case "auto_approval_max_req_reached": // Handle API request errors with special error parsing if (apiRequestFailedMessage || apiReqStreamingFailedMessage) { + // FIXME: ClineError parsing should not be applied to non-Cline providers, but it seems we're using clineErrorMessage below in the default error display const clineError = ClineError.parse(apiRequestFailedMessage || apiReqStreamingFailedMessage) const clineErrorMessage = clineError?.message const requestId = clineError?._error?.request_id - const isClineProvider = clineError?.providerId === "cline" + const isClineProvider = clineError?.providerId === "cline" // FIXME: since we are modifying backend to return generic error, we need to make sure we're not expecting providerId here if (clineError) { if (clineError.isErrorType(ClineErrorType.Balance)) {