zcode 0.1.27: the Start Plan's 405 code 3012 says ZCode's risk control blocked the account, not a network block (#348)
zcode.z.ai answers {"code":3012,"msg":"request has been blocked due to
unusual activity."} with 405. Since 10-24 many accounts get it on every
request, and on several of them ZCode's own app (3.16.3) gets the same 405;
ZCode's support bot calls 3012 platform risk control on the account. The
plugin used to put "though magpie sends it as the ZCode app does; it can
be a network block of this IP" after it, and read that JSON as the edge
firewall's page (EDGE_BLOCKED matched "request has been blocked"), so
ZCode's own words and code were dropped.
Now: ZCode's words with the status and code, then provider
ZCodeRestrictedHint word for word ("ZCode's risk control blocked this
account for unusual activity (code 3012); it rests, and the group's other
providers are used. ..."), which magpie's gateway reads as the account
restricted (2h rest, next member asked) from the next magpie release on.
Only an HTML / errors.aliyun.com block page says the network's address
(provider.BlockedHint's words).
Compared with ZCode 3.16.3's glm/zcode.cjs (downloaded from
cdn-zcode.z.ai, the latest on zcode.z.ai): the Start Plan is sent
unsigned there too (requiresClientRequestSigning is false for
zhipu-account start-plan, off-peak and highspeed; X-Client-Sig/Pow apply
to coding-plan keys on the paas origin), and the headers plugins#348's
curl shows are the plugin's set. No request difference was found that
explains 3012; not tried against a real blocked account.
Run: packages/zcode, Bun 1.4.2, sandbox HOME: 102 pass, 0 fail. The new
start.test.mjs case is red on 0.1.26's index.mjs (1 fail, the 3012
message). bun scripts/check.mjs ok.
This commit is contained in:
@@ -386,10 +386,11 @@ test("a team seat's request goes as the agent sent it, ZCode's token or not", as
|
||||
sentAsIs(await send(auth, agentText), "team.secret", "/api.z.ai/api/anthropic/v1/messages")
|
||||
})
|
||||
|
||||
// magpie's provider.ZCodeStartBlockedHint, word for word
|
||||
const START_BLOCKED = "ZCode's Start Plan still turned this request away, though magpie sends it as the ZCode app does; it can be a network block of this IP, or ZCode checking for something new. Use an account with a GLM Coding Plan, or add another provider to this group"
|
||||
// magpie's provider.ZCodeRestrictedHint and provider.BlockedHint, word for word
|
||||
const START_RESTRICTED = "ZCode's risk control blocked this account for unusual activity (code 3012); it rests, and the group's other providers are used. If the ZCode app fails on this account too, only ZCode support can lift the block"
|
||||
const START_EDGE = "the provider's network firewall blocked requests from this IP; wait a while, or switch to another network or proxy"
|
||||
|
||||
test("the Start Plan turning a request away says what to do about it, as the built-in's zcodeStartExplain did (#425)", async () => {
|
||||
test("the Start Plan's 3012 says ZCode blocked the account, and a block page the network (plugins#348, #425)", async () => {
|
||||
const ask = async (auth, url = "https://api.z.ai/api/anthropic/v1/messages") => {
|
||||
routeToFake()
|
||||
const hooks = await ZCodeAuthPlugin({ client: { auth: { set: async () => {} } } })
|
||||
@@ -397,19 +398,30 @@ test("the Start Plan turning a request away says what to do about it, as the bui
|
||||
const res = await opts.fetch(url, { method: "POST", headers: { "content-type": "application/json", "x-api-key": "zcode" }, body: agentText })
|
||||
return { status: res.status, text: await res.text(), signIn: res.headers.get("x-magpie-sign-in") }
|
||||
}
|
||||
// the block page zcode.z.ai serves: its status, then the hint, and none
|
||||
// of the page's words, which magpie would read as a firewall's
|
||||
answer = () => new Response("<html>Sorry, your request has been blocked due to unusual activity.</html>", { status: 405, headers: { "content-type": "text/html" } })
|
||||
// zcode.z.ai's answer as plugins#348 has it, byte for byte: ZCode's
|
||||
// words with the code, then what they mean, never a network block
|
||||
answer = () => new Response('{ "code": 3012, "msg": "request has been blocked due to unusual activity.", "logid": "202610241036161d8571a39683011267ff" }', { status: 405, headers: { "content-type": "application/json" } })
|
||||
let r = await ask(start("zai"))
|
||||
expect(r.status).toBe(405)
|
||||
expect(JSON.parse(r.text)).toEqual({ type: "error", error: { type: "permission_error", message: "405 Method Not Allowed — " + START_BLOCKED } })
|
||||
expect(r.text).not.toMatch(/request has been blocked/)
|
||||
expect(JSON.parse(r.text)).toEqual({ type: "error", error: { type: "permission_error", message: "request has been blocked due to unusual activity. (405, code 3012) — " + START_RESTRICTED } })
|
||||
expect(r.text).not.toMatch(/network|IP\b|sends it as/)
|
||||
expect(r.signIn).toBe("kept")
|
||||
// code 3012 in JSON: the vendor's own words, then the hint
|
||||
// a bare 405 is the same block
|
||||
answer = () => new Response("", { status: 405 })
|
||||
r = await ask(start("zai"))
|
||||
expect(JSON.parse(r.text).error.message).toBe("405 Method Not Allowed — " + START_RESTRICTED)
|
||||
// code 3012 under another status: the vendor's own words, then the hint
|
||||
answer = () => Response.json({ code: 3012, msg: "method not allowed" }, { status: 403 })
|
||||
r = await ask(start("zai"))
|
||||
expect(r.status).toBe(403)
|
||||
expect(JSON.parse(r.text).error.message).toBe("method not allowed — " + START_BLOCKED)
|
||||
expect(JSON.parse(r.text).error.message).toBe("method not allowed (403, code 3012) — " + START_RESTRICTED)
|
||||
// the edge firewall's block page: its status, then the network's hint,
|
||||
// and none of the page's words
|
||||
answer = () => new Response("<html>Sorry, your request has been blocked due to unusual activity. errors.aliyun.com</html>", { status: 405, headers: { "content-type": "text/html" } })
|
||||
r = await ask(start("zai"))
|
||||
expect(r.status).toBe(405)
|
||||
expect(JSON.parse(r.text)).toEqual({ type: "error", error: { type: "permission_error", message: "405 Method Not Allowed — " + START_EDGE } })
|
||||
expect(r.text).not.toMatch(/request has been blocked/)
|
||||
// any other refusal of the Start Plan goes on as it came
|
||||
answer = () => Response.json({ type: "error", error: { type: "overloaded_error", message: "busy" } }, { status: 529 })
|
||||
r = await ask(start("zai"))
|
||||
|
||||
Reference in New Issue
Block a user