From c1a625d0d5310d8988bc07139ac2487bf4086e1c Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 4 Nov 2026 10:09:07 +0800 Subject: [PATCH] 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: )" 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. --- packages/qoder/index.mjs | 11 ++++++++++- packages/qoder/package.json | 2 +- packages/qoder/raw-429.test.mjs | 25 +++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 packages/qoder/raw-429.test.mjs diff --git a/packages/qoder/index.mjs b/packages/qoder/index.mjs index 3598262..51ca2e9 100644 --- a/packages/qoder/index.mjs +++ b/packages/qoder/index.mjs @@ -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 } } diff --git a/packages/qoder/package.json b/packages/qoder/package.json index e0fa094..204f188 100644 --- a/packages/qoder/package.json +++ b/packages/qoder/package.json @@ -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", diff --git a/packages/qoder/raw-429.test.mjs b/packages/qoder/raw-429.test.mjs new file mode 100644 index 0000000..c1a2202 --- /dev/null +++ b/packages/qoder/raw-429.test.mjs @@ -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") +})