GanHei37443 on X ("workbuddy 全都连接失败是怎么回事啊") showed Routing with
three WorkBuddy Free accounts each "失败 · 16 秒后恢复" on
deepseek-v4.1-flash, and a fourth (WorkBuddy AI) "额度用尽 · 19:07 恢复".
The fourth is the free plan's 24-hour token window, as it says. The three
rested at once for the same request, so the vendor refused that request
the same way on each, with an error the plugin doesn't name (no 11128,
11140, 14018 or content_filter): magpie's "failed". Nothing on the page
said what WorkBuddy answered: the rest carried no status shown and none
of the vendor's words, only the request's details did.
Cause on WorkBuddy's side not found. The owner's WorkBuddy AI account
answers deepseek-v4.1-flash with 200, plain and with DeepSeek Harness's
real main-turn and title bodies, through plugin 0.2.6 (current
5.9.3 headers). The owner's China (copilot.tencent.com) sign-in is
refused 401 since 10-29 and its refresh token too, so the China site,
the reporter's, couldn't be asked. No plugin change.
Fix: a Rest carries Error, the vendor's words (provider.APIError, cut to
300 runes), set where restAfterMarked makes every real rest, kept in the
rest note and sent with each try's and order's rest. The Routing page's
stage row, Accounts table and per-model rest line say the status for a
failure of no named kind ("500 · failed · back in 16s") and show the
vendor's words as the tooltip. Kinds that name themselves read as before.
No new strings.
Run (mote):
- go test ./internal/gateway -run 'TestRestCarriesTheVendorsWords|TestCarried|TestOneRequestDoesNotClimb': ok
- broken by hand: without Error set, TestRestCarriesTheVendorsWords is red
("the rest says \"\", not the vendor's words")
- gofmt -l; go vet ./internal/gateway for darwin, linux, windows: clean
- GUI, new routing-rest-error.test.cjs (5 languages, 1100 and 420px):
chromium 10/10 on mote; webkit on Linux (wsl magpie-desktop) with
routing-model-rest, rest-probed, routing-rest-off: 50/50. WebKit
doesn't launch on mote at the moment (browserType.launch timeout at
180s, untouched routing-model-rest the same), so it ran there.
- chromium on Linux: routing-rest-error, routing-model-rest, rest-probed,
routing-rest-off, provider-limit-rest, rest-try-now, key-rest-date,
routing-lifted-elsewhere, routing-day-tallies: 126/126
- broken by hand: origin/main's client.js with the new GUI test is red
("a@x.test: the stage row says failed · back in 16 s")
- rebased on 03f609e3f: the Go test and routing-rest-error again ok;
i18n-keys red on "Unmarked" in internal/usage/search_calls_test.go,
which this change doesn't touch: #4524
Not tried: the China WorkBuddy site (no signed-in account), so the
reporter's actual error text is unknown; the Windows desktop app itself;
the full Go and GUI suites (owner's rule: not held behind them).
49 lines
1.9 KiB
Go
49 lines
1.9 KiB
Go
package gateway
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
"unicode/utf8"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// A rest after a failure that names no kind ("failed") carries what the
|
|
// vendor said, kept with the rest and sent to the app, which shows it
|
|
// beside the row (GanHei37443 on X: three WorkBuddy accounts each
|
|
// "failed · back in 16s", and nothing on the page said why).
|
|
func TestRestCarriesTheVendorsWords(t *testing.T) {
|
|
clineRestsCleared(t)
|
|
s := &Server{}
|
|
p := provider.Provider{ID: "custom", Chat: "https://relay.example/v1", Key: "k"}
|
|
c := candidate{p: p, model: "deepseek-v4.1-flash", rest: p.ID}
|
|
|
|
r := s.restAfter(c, 500, nil, []byte(`{"error":{"message":"model deepseek-v4.1-flash is not available for your plan","type":"server_error"}}`))
|
|
if r.Why != failOther || r.Status != 500 {
|
|
t.Fatalf("rests %s at %d, want a plain failure at 500", r.Why, r.Status)
|
|
}
|
|
if !strings.Contains(r.Error, "not available for your plan") {
|
|
t.Fatalf("the rest says %q, not the vendor's words", r.Error)
|
|
}
|
|
kept, ok := restOf(p.ID)
|
|
if !ok || kept.Error != r.Error {
|
|
t.Fatalf("the kept rest says %q (resting %v), want %q", kept.Error, ok, r.Error)
|
|
}
|
|
b, _ := json.Marshal(r)
|
|
if !strings.Contains(string(b), `"error":"`) {
|
|
t.Fatalf("the app isn't sent the words: %s", b)
|
|
}
|
|
|
|
// a body with no words of its own says its status; a long one is cut
|
|
// short on a rune, the request's details keeping it whole
|
|
if r := s.restAfter(c, 502, nil, nil); !strings.HasPrefix(r.Error, "Bad Gateway") {
|
|
t.Errorf("an empty 502 rests saying %q, want its status text", r.Error)
|
|
}
|
|
long := strings.Repeat("服务", 400)
|
|
r = s.restAfter(c, 500, nil, []byte(`{"error":{"message":"`+long+`"}}`))
|
|
if n := utf8.RuneCountInString(r.Error); n > restErrorRunes+1 || n < restErrorRunes || !utf8.ValidString(r.Error) {
|
|
t.Errorf("a long error is kept as %d runes (valid %v), want %d", n, utf8.ValidString(r.Error), restErrorRunes)
|
|
}
|
|
}
|