qoder 0.2.60: a 429 with no quota in it shows Qoder's status, code and own reply (QwenWork flash through dsh: "All models failed")

sherlock (Discord): the same QwenWork account works in ZCode, and dsh's
auto-review failed with "QwenWork: usage limit reached: All models failed".
"All models failed" is Qoder's own message: nothing in the plugin or magpie
builds it. The plugin only put "usage limit reached:" before it, which hid
the status, code and reply it came with. The failure now ends with
"(Qoder replied HTTP 429, code N: <reply>)" for a 429 or quota-worded reply
with no quota code; quota codes keep their short words.

The cause of the 429 itself is NOT found. dsh's reviewer sends a system
prompt, one user message, temperature 0, no tools and no max_tokens (read
from dsh-experimental-auto-review); the plugin sends no temperature and
32000 max_tokens for it. Nothing in qoderBody differs in a way known to
fail. This release makes the next report carry Qoder's reply.

Run on mote (bun): packages/qoder bun test 385 pass, 0 fail (raw-429.test.mjs
new); bun scripts/check.mjs qoder ok. Broken by hand (old failure()): 2 of the
3 new tests fail. Not tried: a real QwenWork account.
This commit is contained in:
yetone
2026-11-04 10:09:07 +08:00
parent 1865969e1f
commit c1a625d0d5
3 changed files with 36 additions and 2 deletions
+10 -1
View File
@@ -1600,7 +1600,16 @@ function failure(status, text) {
const said = msg && msg !== STATUS_CODES[status] ? ` (Qoder said ${status}: ${msg.slice(0, 300)})` : ""
return { status: 401, message: "the sign-in lapsed — sign in again" + said, lapsed: true }
}
if (status === 429 || msg.toLowerCase().includes("quota")) return { status: 429, message: "usage limit reached: " + msg }
// Qoder's words go with the status and code they came in, and the reply
// itself when it says more than the message: a 429 that names no quota
// ("All models failed", QwenWork) is not shown as an account's limit
// with nothing to tell it apart (dsh, QwenWork flash)
if (status === 429 || msg.toLowerCase().includes("quota")) {
const raw = String(text ?? "").trim()
const seen = `Qoder replied HTTP ${status}${code ? `, code ${code}` : ""}`
const body = raw && raw !== msg ? `: ${raw.slice(0, 400)}` : ""
return { status: 429, message: `usage limit reached: ${msg} (${seen}${body})` }
}
return { status, message: msg }
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-qoder-auth",
"version": "0.2.59",
"version": "0.2.60",
"description": "Qoder and QwenWork (千问办公) subscriptions in OpenCode and magpie: qoder.com, qoder.cn, gateway.qwenwork.cn and the enterprise flagship, VPC and dedicated domains",
"type": "module",
"main": "./opencode.mjs",
+25
View File
@@ -0,0 +1,25 @@
// A 429 that names no quota carries Qoder's status, code and own reply, so a
// user sees what Qoder said and not only "usage limit reached"
// (QwenWork flash through dsh: "All models failed").
import { test, expect } from "bun:test"
import { _internal } from "./index.mjs"
test("a 429 with no quota in it shows Qoder's status, code and reply", () => {
const body = JSON.stringify({ code: "9001", message: "All models failed", details: "{\"error\":{\"message\":\"flash: rate limited\"}}" })
const f = _internal.failure(429, body)
expect(f.status).toBe(429)
expect(f.message.startsWith("usage limit reached: All models failed")).toBe(true)
expect(f.message).toContain("HTTP 429")
expect(f.message).toContain("code 9001")
expect(f.message).toContain("flash: rate limited")
})
test("an empty 429 still says its status", () => {
const f = _internal.failure(429, "")
expect(f.status).toBe(429)
expect(f.message).toContain("HTTP 429")
})
test("a quota code keeps its short words", () => {
expect(_internal.failure(429, JSON.stringify({ code: "112", message: "credits used up" })).message).toBe("usage limit reached: credits used up")
})