qoder 0.2.12: a chat Qoder refuses (401/403) keeps Qoder's own reason in the error

Yayoi_no_yume on X: a request made right after signing in came back
"Qoder: the sign-in lapsed — sign in again" (401), and only installing and
signing in to Qoder CLI made it work. failure() replaced whatever Qoder said
with that fixed text, so the real reason for the refusal could not be seen.
The message is the same, with "(Qoder said <status>: <its message>)" added
when Qoder gave one; the account is still left unmarked (X-Magpie-Sign-In:
kept), as before.

usage.test.mjs gains the case (a 401 whose body says why); it fails on
0.2.11 and passes. bun test (89 pass) and scripts/check.mjs qoder under a
scratch HOME pass. Not tried against Qoder itself (no Qoder account here),
so the cause of the reporter's 401 is not known yet.
This commit is contained in:
yetone
2026-10-10 01:10:39 +08:00
parent 5189b287e7
commit aa2d99bd13
3 changed files with 15 additions and 4 deletions
+7 -1
View File
@@ -151,12 +151,18 @@ const ASK = { method: "POST", body: JSON.stringify({ model: "qmodel", messages:
test("a refused chat, 401 or 403, is the built-in's 401 and leaves the account unmarked", async () => {
for (const status of [401, 403]) {
const { fetch } = await chat(LISTING, () => new Response("nope", { status }))
const { fetch } = await chat(LISTING, () => new Response("", { status }))
const res = await fetch(API_CHAT, ASK)
expect(res.status).toBe(401)
expect(res.headers.get("X-Magpie-Sign-In")).toBe("kept")
expect((await res.json()).error.message).toBe("the sign-in lapsed — sign in again")
}
// what Qoder says of the refusal is kept: a 401 just after signing in
// has some other reason, and only Qoder's words tell it
const said = await chat(LISTING, () => new Response(JSON.stringify({ message: "device not trusted" }), { status: 401 }))
const r = await said.fetch(API_CHAT, ASK)
expect([r.status, r.headers.get("X-Magpie-Sign-In")]).toEqual([401, "kept"])
expect((await r.json()).error.message).toBe("the sign-in lapsed — sign in again (Qoder said 401: device not trusted)")
// refused in the stream, before any answer: the same
const sse = (v) => new Response(`data: ${JSON.stringify(v)}\n\n`, { headers: { "Content-Type": "text/event-stream" } })
const { fetch } = await chat(LISTING, () => sse({ statusCodeValue: 403, body: "" }))