summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorFrank <[email protected]>2026-04-23 13:13:26 -0400
committerFrank <[email protected]>2026-04-23 13:13:29 -0400
commit1e439b8226a66dcec0d65751f5cdb50a2b7bc979 (patch)
treea744a2cbd3ba70faabb40d5931291fb5d5eeab81 /packages
parent8b2f8355b22414a768c4a594d7a7101a4f72b00f (diff)
downloadopencode-1e439b8226a66dcec0d65751f5cdb50a2b7bc979.tar.gz
opencode-1e439b8226a66dcec0d65751f5cdb50a2b7bc979.zip
sync
Diffstat (limited to 'packages')
-rw-r--r--packages/console/app/src/routes/zen/util/handler.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/console/app/src/routes/zen/util/handler.ts b/packages/console/app/src/routes/zen/util/handler.ts
index d9dc45001..87d4a4d0a 100644
--- a/packages/console/app/src/routes/zen/util/handler.ts
+++ b/packages/console/app/src/routes/zen/util/handler.ts
@@ -187,6 +187,8 @@ export async function handler(
// Try another provider => stop retrying if using fallback provider
if (
res.status !== 200 &&
+ // ie. 400 error is usually provider error like malformed request
+ res.status !== 400 &&
// ie. openai 404 error: Item with id 'msg_0ead8b004a3b165d0069436a6b6834819896da85b63b196a3f' not found.
res.status !== 404 &&
// ie. cannot change codex model providers mid-session
@@ -226,7 +228,7 @@ export async function handler(
logger.debug("STATUS: " + res.status + " " + res.statusText)
// Handle non-streaming response
- if (!isStream || res.status === 429) {
+ if (!isStream || [400, 404, 429].includes(res.status)) {
const json = await res.json()
await rateLimiter?.track()
if (json.usage) {
@@ -238,6 +240,9 @@ export async function handler(
await reload(billingSource, authInfo, costInfo)
json.cost = calculateOccurredCost(billingSource, costInfo)
}
+ if (res.status === 400) {
+ logger.metric({ "error.response": JSON.stringify(json) })
+ }
if (json.error?.message) {
json.error.message = `Error from provider${providerInfo.displayName ? ` (${providerInfo.displayName})` : ""}: ${json.error.message}`
}
@@ -393,7 +398,7 @@ export async function handler(
type: "error",
error: {
type: "error",
- message: error.message,
+ message: "Internal server error",
},
}),
{ status: 500 },