qoder 0.2.24: Qoder's 400 "Error in upstream response" is a 502, so magpie retries or falls back (SlouchyQuill507 on Discord)
SlouchyQuill507 (Discord, qoder-cn) reported Qoder failures of the model's
own vendor, "Error in upstream response", reaching magpie as a 400 invalid
request: the client's fault, never asked again or of another account.
failure() now maps a message saying "Error in upstream response" to a 502
(no X-Magpie-Sign-In, the account untouched), after the queue, quota and
request codes, so a 400 with one of Qoder's request codes (406, 416, ...)
and any other 400 stay 400. It covers an HTTP 400 and a 400 in the
stream's statusCodeValue envelope, JSON or plain text. magpie still tells
an overflow that fails this way apart by its size (tooLongUnsaid takes 502
as well as 400).
Test: usage.test.mjs "Qoder's 400 \"Error in upstream response\" is a
502" - fixtures from the reported literal text, four shapes through the
loader's fetch, plus genuine 400s kept. Red on the old index.mjs (400 for
each), green with the change.
Run on origin/main 6fd976a: TMPDIR=<scratch> HOME=<scratch>/home bun test
(whole repo) 1919 pass 0 fail across 173 files; bun scripts/check.mjs ok.
This commit is contained in:
@@ -849,6 +849,14 @@ const QUOTA_CODES = new Set(["110", "112", "113", "114", "115", "116", "117", "1
|
||||
// supported, input too long, too many media, a custom model's service
|
||||
const REQUEST_CODES = new Set(["406", "416", "430", "80411", "80412", "100400", "100401", "100403"])
|
||||
const BUSY_WAIT = 30
|
||||
// UPSTREAM_FAILED is Qoder saying the model's own vendor behind it failed:
|
||||
// "Error in upstream response", which Qoder sends as a 400 (SlouchyQuill507
|
||||
// on Discord, qoder-cn). Nothing is wrong with the request or the account,
|
||||
// so it is a 502, which magpie asks again or of another account, not a
|
||||
// 400 that ends the turn as the client's fault. A request too long for the
|
||||
// model fails the same way, and magpie tells that one apart by its size
|
||||
// (tooLongUnsaid), at 502 as at 400.
|
||||
const UPSTREAM_FAILED = /\berror in upstream response\b/i
|
||||
|
||||
function failure(status, text) {
|
||||
if (status < 400 || status > 599) status = 502
|
||||
@@ -894,6 +902,7 @@ function failure(status, text) {
|
||||
}
|
||||
if (QUOTA_CODES.has(code)) return { status: 429, message: "usage limit reached: " + msg, signIn: "" }
|
||||
if (REQUEST_CODES.has(code)) return { status: 400, message: `Qoder refused the request (${code}): ${msg}`, signIn: "" }
|
||||
if (UPSTREAM_FAILED.test(msg)) return { status: 502, message: msg, signIn: "" }
|
||||
// a refused chat is the built-in's 401, which never marked the account
|
||||
// lapsed: only a refused refresh did (errorResponse says kept). Qoder's
|
||||
// own words go with it: a 401 right after signing in isn't a lapsed
|
||||
|
||||
Reference in New Issue
Block a user