From 4e0026661c692a1c09acac5f4652ca6d85147d89 Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 12 Nov 2026 22:53:32 +0800 Subject: [PATCH] gateway: CodeArts's "request param is invalid" is the request's, nobody rests (Abandon332 on X, #6342) Huawei's gateway answers a parameter it can't take (the codearts plugin sent `stop` as an array; plugin 0.3.15 sends a string) with InferHub.001001005.400 inside a 200. magpie read it as a plain 400 and rested the account, 182 times in the report. The code joins shapeWords, so a member behind it is asked and the one that refused doesn't rest, as for any request shape a vendor can't read. Run (mica): TestCodeArtsInvalidParamIsTheRequests, shapeRefused, custom-tool tests; go vet on darwin, windows, linux nogui; gofmt clean. The new test was red before the regex change. Not tried: a real CodeArts account; the whole suite (started after the tag). The last member in a group still rests as before, since shapeRefused only applies when another is left. --- internal/gateway/codearts_param_test.go | 16 ++++++++++++++++ internal/gateway/fallback.go | 6 ++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 internal/gateway/codearts_param_test.go diff --git a/internal/gateway/codearts_param_test.go b/internal/gateway/codearts_param_test.go new file mode 100644 index 000000000..3007add0f --- /dev/null +++ b/internal/gateway/codearts_param_test.go @@ -0,0 +1,16 @@ +package gateway + +import "testing" + +// Huawei CodeArts answers a request parameter it can't take (a `stop` array, +// #6342) with a 400 that names a code only: the request's content, not the +// account, so the next member is asked and nobody rests. +func TestCodeArtsInvalidParamIsTheRequests(t *testing.T) { + body := `{"error":{"message":"华为云 CodeArts: The request param is invalid, Please check it (InferHub.001001005.400)"}}` + if !shapeRefused(400, []byte(body)) { + t.Errorf("no next member over: %s", body) + } + if shapeRefused(400, []byte(`{"error":{"message":"InferHub.4004.200 benefit not found"}}`)) { + t.Error("another CodeArts code counted as the request's shape") + } +} diff --git a/internal/gateway/fallback.go b/internal/gateway/fallback.go index 02e584dd8..c16bb01e0 100644 --- a/internal/gateway/fallback.go +++ b/internal/gateway/fallback.go @@ -1760,7 +1760,9 @@ func promptRefused(status int, body []byte) bool { // JSON schema: OpenCode Go's 400 "JSON schema exceeds the maximum nesting // depth of 10 levels" on muse-spark-1.3-contributor for Claude Code's MCP // tools (#1870), which another member's model may take as they are; and a -// custom tool turned away (customToolRefusal, DeepSeek's "Unsupported +// Huawei CodeArts's HTTP 200 "The request param is invalid" over a +// parameter it can't take, InferHub.001001005.400 (a `stop` array, #6342), +// which the plugin now sends as a string; and a custom tool turned away (customToolRefusal, DeepSeek's "Unsupported // custom tool: 'exec'", #2656) where no translation took it in. A // request missing what every API requires ("field required") or too long // for the model isn't one. Google's refusal of a function declaration's @@ -1775,7 +1777,7 @@ func promptRefused(status int, body []byte) bool { // the only field set." (#5374, worksyang) — a description beside an // anyOf, which Google's Schema takes alone, the reporter's same tools // another member took. -var shapeWords = lazyre.New(`(?i)failed to deserialize|unknown (item |content |input )?(type|variant|field|parameter)|unknown_parameter|unrecognized (request argument|field|parameter)|extra (inputs|fields) are not permitted|additional properties are not allowed|schema exceeds the maximum (nesting )?depth|schema[^"]{0,60}\bnesting depth\b|function_declarations\[\d+\]\.parameters\b|schema specified other fields alongside any_?of`) +var shapeWords = lazyre.New(`(?i)failed to deserialize|unknown (item |content |input )?(type|variant|field|parameter)|unknown_parameter|unrecognized (request argument|field|parameter)|extra (inputs|fields) are not permitted|additional properties are not allowed|schema exceeds the maximum (nesting )?depth|schema[^"]{0,60}\bnesting depth\b|function_declarations\[\d+\]\.parameters\b|schema specified other fields alongside any_?of|InferHub\.001001005\.400`) // unsaidWords are Command Code's Provider API turning a request away with // nothing but a trace id: {"message":"invalid request error trace_id: