gateway: an Antigravity account Google suspended rests as restricted, and the next account serves
Google answers a Code Assist account it suspended with 403
PERMISSION_DENIED "This service has been disabled in this account for
violation of Terms of Service. Please submit an appeal to continue using
this product." Read as an unknown failure, it failed over but rested a
minute, doubling to the ten-minute cap, so the suspended account was
asked again (and refused, a wasted round trip first in line) every ten
minutes for good, and the Routing page said only "failed".
The refusal is about the account, not the model or the request: it is
now failRestricted (googleSuspended, on an Antigravity or Gemini CLI
account, 403, Google's exact words), so it rests restrictedRest (2h) as
"account restricted by the vendor", with the Routing page's lift for an
appeal that went through, and its usage isn't asked again. Unlike
WorkBuddy's and ZCode's risk control, it is not walled off from the
provider's other accounts (riskRefused): the service was disabled
before the request came, so the next account is asked as before.
Run (mote, at this tree on origin/main d2c29abe7):
- go test -run TestAntigravitySuspended ./internal/gateway: red on the
old code (all three tests: failOther, a 1-minute "backoff" rest, no
rest for the last one), green after.
- Broken by hand: without the riskRefused exclusion, the turn ends 403
and u2 is never asked (TestAntigravitySuspendedRestsAsRestricted red).
- go test ./internal/gateway (whole package), go vet for darwin, linux
and windows, gofmt.
Not tried: a real suspended Google account (the fixture is the
reporter's message as their agent showed it, in Google's error shape);
Gemini CLI's own wording of the same suspension is assumed the same.
Reported-by: bestony (Discord)
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// antigravitySuspended is Google's answer for an Antigravity account it
|
||||
// suspended, as bestony's agent showed it on Discord (#feedback, 11-06):
|
||||
// "Error 403, Message: Antigravity: This service has been disabled in this
|
||||
// account for violation of Terms of Service. Please submit an appeal to
|
||||
// continue using this product., Status: PERMISSION_DENIED".
|
||||
const antigravitySuspended = `{"error":{"code":403,"message":"This service has been disabled in this account for violation of Terms of Service. Please submit an appeal to continue using this product.","status":"PERMISSION_DENIED"}}`
|
||||
|
||||
// An account Google suspended is out until an appeal lifts it: the request
|
||||
// goes on to the next account, and the suspended one rests as restricted
|
||||
// (two hours, lifted by hand on the Routing page), not the minute of an
|
||||
// unknown failure that doubled to ten and had it asked, and refused, every
|
||||
// ten minutes for good.
|
||||
func TestAntigravitySuspendedRestsAsRestricted(t *testing.T) {
|
||||
var asked []string
|
||||
s, askedUsage := antigravityGroupFor(t, []string{"u1@example.com", "u2@example.com"}, "gemini-3.8-flash", func(w http.ResponseWriter, r *http.Request) {
|
||||
who := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ")
|
||||
asked = append(asked, who)
|
||||
if who == "u1@example.com" {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
io.WriteString(w, antigravitySuspended)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "text/event-stream")
|
||||
io.WriteString(w, sse(`data: {"response":{"candidates":[{"content":{"role":"model","parts":[{"text":"from u2"}]},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":10,"candidatesTokenCount":3}}}`))
|
||||
})
|
||||
turn := func(n int) (int, string) {
|
||||
body := fmt.Sprintf(`{"model":"antigravity/gemini-3.8-flash","stream":false,"messages":[{"role":"user","content":"hi %d"}]}`, n)
|
||||
rec := httptest.NewRecorder()
|
||||
s.Handler().ServeHTTP(rec, httptest.NewRequest("POST", "/v1/chat/completions", strings.NewReader(body)))
|
||||
return rec.Code, rec.Body.String()
|
||||
}
|
||||
if code, out := turn(1); code != 200 || !strings.Contains(out, "from u2") || !slices.Equal(asked, []string{"u1@example.com", "u2@example.com"}) {
|
||||
t.Fatalf("the turn: %d %s, asked %v", code, out, asked)
|
||||
}
|
||||
r := lastRoute(s)
|
||||
if len(r.Tries) != 2 || r.Tries[0].Status != 403 || r.Tries[0].Fail != failRestricted || r.Tries[0].Rest == nil {
|
||||
t.Fatalf("the suspended try: %+v", r.Tries)
|
||||
}
|
||||
rest := r.Tries[0].Rest
|
||||
if d := time.Until(rest.Until); rest.By != "restricted" || rest.Key != "antigravity@u1@example.com" || d < restrictedRest-time.Minute || d > restrictedRest {
|
||||
t.Fatalf("u1 rests %v by %q under %q, not %v as restricted", d, rest.By, rest.Key, restrictedRest)
|
||||
}
|
||||
if *askedUsage != 0 {
|
||||
t.Fatalf("the suspended account's usage was asked again %d times", *askedUsage)
|
||||
}
|
||||
for n := 2; n <= 4; n++ {
|
||||
asked = nil
|
||||
if code, _ := turn(n); code != 200 || !slices.Equal(asked, []string{"u2@example.com"}) {
|
||||
t.Fatalf("turn %d: %d, asked %v", n, code, asked)
|
||||
}
|
||||
}
|
||||
// past the ten minutes an unknown failure rests at most
|
||||
if got, ok := restOf("antigravity@u1@example.com"); !ok || got.Why != failRestricted || time.Until(got.Until) <= longestRetry {
|
||||
t.Fatalf("u1's rest %+v %v", got, ok)
|
||||
}
|
||||
}
|
||||
|
||||
// The last account left, suspended, rests too, and the agent is told
|
||||
// Google's own words; lifted on the Routing page (an appeal went through),
|
||||
// it is asked again.
|
||||
func TestAntigravitySuspendedAloneRests(t *testing.T) {
|
||||
n, back := 0, false
|
||||
s, _ := antigravityGroupFor(t, []string{"u1@example.com"}, "gemini-3.8-flash", func(w http.ResponseWriter, r *http.Request) {
|
||||
n++
|
||||
if back {
|
||||
w.Header().Set("Content-Type", "text/event-stream")
|
||||
io.WriteString(w, sse(`data: {"response":{"candidates":[{"content":{"role":"model","parts":[{"text":"back"}]},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":10,"candidatesTokenCount":1}}}`))
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
io.WriteString(w, antigravitySuspended)
|
||||
})
|
||||
turn := func() (int, string) {
|
||||
rec := httptest.NewRecorder()
|
||||
s.Handler().ServeHTTP(rec, httptest.NewRequest("POST", "/v1/chat/completions", strings.NewReader(`{"model":"antigravity/gemini-3.8-flash","stream":false,"messages":[{"role":"user","content":"hi"}]}`)))
|
||||
return rec.Code, rec.Body.String()
|
||||
}
|
||||
if code, out := turn(); code != 403 || !strings.Contains(out, "violation of Terms of Service") || n != 1 {
|
||||
t.Fatalf("%d after %d: %s", code, n, out)
|
||||
}
|
||||
if got, has := restOf("antigravity@u1@example.com"); !has || got.Why != failRestricted || got.By != "restricted" {
|
||||
t.Fatalf("the last one's rest %+v %v", got, has)
|
||||
}
|
||||
if !s.Unrest("antigravity@u1@example.com") {
|
||||
t.Fatal("rest not lifted")
|
||||
}
|
||||
back = true
|
||||
if code, out := turn(); code != 200 || !strings.Contains(out, "back") {
|
||||
t.Fatalf("after the appeal: %d %s", code, out)
|
||||
}
|
||||
}
|
||||
|
||||
// Only Google's suspension of a Google sign-in is read so: another 403 from
|
||||
// Antigravity, and the same words from a key's relay, fail as before.
|
||||
func TestAntigravitySuspendedIsGooglesAlone(t *testing.T) {
|
||||
ag := candidate{p: provider.Provider{ID: "antigravity", Account: &provider.Account{Agent: "antigravity", User: "u"}}}
|
||||
gem := candidate{p: provider.Provider{ID: "gemini", Account: &provider.Account{Agent: "gemini", User: "u"}}}
|
||||
key := candidate{p: provider.Provider{ID: "relay", Key: "k"}}
|
||||
said := "Antigravity: This service has been disabled in this account for violation of Terms of Service. Please submit an appeal to continue using this product."
|
||||
for _, c := range []struct {
|
||||
c candidate
|
||||
status int
|
||||
body string
|
||||
want string
|
||||
}{
|
||||
{ag, 403, antigravitySuspended, failRestricted},
|
||||
{ag, 403, said, failRestricted},
|
||||
{gem, 403, antigravitySuspended, failRestricted},
|
||||
{ag, 403, `{"error":{"code":403,"message":"The caller does not have permission","status":"PERMISSION_DENIED"}}`, failOther},
|
||||
{ag, 400, antigravitySuspended, failOther},
|
||||
{key, 403, antigravitySuspended, failOther},
|
||||
} {
|
||||
if got := failureOf(c.c, c.status, []byte(c.body)); got != c.want {
|
||||
t.Errorf("%s %d %s: %s, want %s", c.c.p.ID, c.status, c.body, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1827,9 +1827,13 @@ func elsewhere(left []candidate, c candidate) []candidate {
|
||||
// request as well as the account, so the same request sent on to another
|
||||
// of its accounts trips it there too. Another computer's magpie that
|
||||
// says so (remoteModelRest) speaks for one account of its own, and its
|
||||
// other models may be other vendors: it walls off nothing here.
|
||||
// other models may be other vendors: it walls off nothing here. Nor does
|
||||
// Google's suspension of an account for its terms (googleSuspended): it
|
||||
// says the service was disabled in this account before the request came,
|
||||
// a ruling on the account, not on what was sent, so the provider's other
|
||||
// accounts are asked (bestony on Discord).
|
||||
func riskRefused(c candidate, status int, header http.Header, body []byte) bool {
|
||||
return failureOf(c, status, body) == failRestricted && !remoteModelRest(c, failRestricted, header)
|
||||
return failureOf(c, status, body) == failRestricted && !remoteModelRest(c, failRestricted, header) && !googleSuspended(c.p, carriedStatus(status, body), body)
|
||||
}
|
||||
|
||||
// elsewhereWeighed is elsewhere on a list of candidates beside their
|
||||
|
||||
@@ -712,7 +712,29 @@ func restrictedRefused(p provider.Provider, status int, body []byte) bool {
|
||||
if restrictedSaid(status, body) {
|
||||
return true
|
||||
}
|
||||
return isWorkBuddy(p) && provider.WBRestricted(status, wordsOf(body))
|
||||
return isWorkBuddy(p) && provider.WBRestricted(status, wordsOf(body)) || googleSuspended(p, status, body)
|
||||
}
|
||||
|
||||
// googleToS is Google's 403 PERMISSION_DENIED for a Code Assist account it
|
||||
// suspended: "This service has been disabled in this account for violation
|
||||
// of Terms of Service. Please submit an appeal to continue using this
|
||||
// product." (bestony on Discord, an Antigravity account, 11-06).
|
||||
var googleToS = regexp.MustCompile(`(?i)disabled in this account for violation of Terms of Service`)
|
||||
|
||||
// googleSuspended says Google suspended p, an account signed in to
|
||||
// Antigravity or Gemini CLI, for its terms (googleToS): the account, not
|
||||
// the model or the request, until an appeal goes through. Read as any
|
||||
// failure, it rested a minute, doubling to ten, and was asked again, and
|
||||
// refused, every ten minutes for good. Another vendor's same words are its
|
||||
// own, and aren't read so.
|
||||
func googleSuspended(p provider.Provider, status int, body []byte) bool {
|
||||
if status != http.StatusForbidden {
|
||||
return false
|
||||
}
|
||||
if a := accountAgent(p); a != "antigravity" && a != "gemini" {
|
||||
return false
|
||||
}
|
||||
return googleToS.Match(wordsOf(body))
|
||||
}
|
||||
|
||||
// isWorkBuddy is whether p is a WorkBuddy account, either build's: the
|
||||
|
||||
Reference in New Issue
Block a user