pppuuu (Discord) tested an Antigravity model, got Google's 403 "Verify your account to continue." with a link, and opening the link gave Google's own "400. That's an error. The server cannot process the request because it is malformed." What magpie showed was checked first, and it was Google's validation_url whole: a realistic VALIDATION_REQUIRED body (ErrorInfo metadata with validation_url, validation_error_message, validation_url_link_text, a google.rpc.Help detail, & written raw and as &) sent through the Antigravity model test (TestAntigravityModelTest) and through the gateway to an agent (TestVerifyLinkWhole) shows the URL with every parameter on the old code too. Google's own Antigravity flow gives the same 400 to many accounts (discuss.ai.google.dev 119780: cleared google.com cookies, Chrome, or removing Antigravity from third-party access fixed it). What differed from Google's own client, and is fixed here: - Gemini CLI (classifyValidationRequiredError) opens the google.rpc.Help detail's link first, past a "Learn more" one, then the ErrorInfo's validation_link, then validation_url. magpie took validation_url first and never read validation_link. It now takes them in Gemini CLI's order. - Metadata was read as map[string]string, so one non-string value made the whole body unreadable and the link was lost; values are read one by one. - A message magpie already put the link in, passed on again as a JSON error body (a Remote magpie's, the gateway's), has & as &; the raw read stopped at the \ and found no link. It is read from the decoded words now. Tests: TestVerificationLinkWhole and TestVerificationLinkAsGeminiCLI (provider), TestVerifyLinkWhole and a verify case in TestAntigravityModelTest (gateway). Run on mote: go test -run 'TestVerification|TestAPIError' ./internal/provider ok; go test -run 'TestAntigravityModelTest|TestVerify|Restricted' ./internal/gateway ok; go vet (darwin, linux, windows) of internal/provider and go vet internal/gateway ok; go test ./internal/provider: ok (178s). Broken by hand: with the old test.go, TestVerificationLinkWhole (escaped read-back) and TestVerificationLinkAsGeminiCLI (Help link) are red; the gateway cases pass on the old code too, which is the evidence the shown link was already whole. Not tried: a real account Google wants verified (none here), and pppuuu's exact body and link, which aren't known; whether Google's Help link and validation_url ever differ is not known.
75 lines
4.2 KiB
Go
75 lines
4.2 KiB
Go
package provider
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// realVerifyURL is a validation_url in the shape Google's VALIDATION_REQUIRED
|
|
// gives it: accounts.google.com/signin/continue with sarp, scc, a continue
|
|
// URL of its own, a plt token and the flow's name (the forum reports cut it
|
|
// after continue=; gemini-cli's tests after scc=1).
|
|
const realVerifyURL = "https://accounts.google.com/signin/continue?sarp=1&scc=1&continue=https://developers.google.com/gemini-code-assist/auth/auth_success_gemini%3Fsrc%3Dag%26x%3D1&plt=AKgnsbvK-3x_Yq9Zt0lPq2vN7m8w-AbCdEf_0123456789AbCdEfGhIjKlMnOpQrStUvWxYz&flowName=GlifWebSignIn&authuser=0"
|
|
|
|
func realVerifyBody(escape bool) []byte {
|
|
u := realVerifyURL
|
|
body := map[string]any{"error": map[string]any{
|
|
"code": 403, "message": "Verify your account to continue.", "status": "PERMISSION_DENIED",
|
|
"details": []any{
|
|
map[string]any{"@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "VALIDATION_REQUIRED", "domain": "cloudcode-pa.googleapis.com",
|
|
"metadata": map[string]any{"validation_error_message": "Verify your account to continue.", "validation_url_link_text": "Verify your account", "validation_url": u,
|
|
"validation_learn_more_link_text": "Learn more", "validation_learn_more_url": "https://support.google.com/accounts?p=al_alert"}},
|
|
map[string]any{"@type": "type.googleapis.com/google.rpc.Help", "links": []any{
|
|
map[string]any{"description": "Further action is required to use this service. Navigate to the following URL to complete verification:\n\n" + u + "\n\nLearn more:\n\nhttps://support.google.com/accounts?p=al_alert\n", "url": u},
|
|
map[string]any{"description": "Learn more", "url": "https://support.google.com/accounts?p=al_alert"},
|
|
}},
|
|
},
|
|
}}
|
|
var b strings.Builder
|
|
enc := json.NewEncoder(&b)
|
|
enc.SetEscapeHTML(escape) // Google's ESF writes &, Go's default writes &
|
|
_ = enc.Encode(body)
|
|
return []byte(b.String())
|
|
}
|
|
|
|
func TestVerificationLinkWhole(t *testing.T) {
|
|
for _, esc := range []bool{false, true} {
|
|
b := realVerifyBody(esc)
|
|
if link, ok := Verification(b); !ok || link != realVerifyURL {
|
|
t.Fatalf("escape %v: %q %v", esc, link, ok)
|
|
}
|
|
msg := "Antigravity: " + APIError(b, "403 Forbidden")
|
|
if !strings.Contains(msg, " open "+realVerifyURL+" in a browser") {
|
|
t.Fatalf("escape %v: %s", esc, msg)
|
|
}
|
|
if link, _ := Verification([]byte(msg)); link != realVerifyURL {
|
|
t.Fatalf("escape %v: from the message %q", esc, link)
|
|
}
|
|
// the message passed on again as an error body (a Remote magpie's,
|
|
// the gateway's answer to an agent): the link read back whole
|
|
again, _ := json.Marshal(map[string]any{"error": map[string]any{"message": msg}})
|
|
if link, _ := Verification(again); link != realVerifyURL {
|
|
t.Fatalf("escape %v: from %s: %q", esc, again, link)
|
|
}
|
|
if got := APIError(again, ""); got != msg {
|
|
t.Fatalf("escape %v: %s", esc, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
// The link is the one Gemini CLI opens: the Help detail's (past a "Learn
|
|
// more"), then validation_link, then validation_url.
|
|
func TestVerificationLinkAsGeminiCLI(t *testing.T) {
|
|
for _, c := range []struct{ body, want string }{
|
|
{`{"error":{"details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"VALIDATION_REQUIRED","domain":"cloudcode-pa.googleapis.com","metadata":{"validation_url":"https://accounts.google.com/meta"}},{"@type":"type.googleapis.com/google.rpc.Help","links":[{"description":"Learn more","url":"https://support.google.com/accounts?p=al_alert"},{"description":"Complete validation","url":"https://accounts.google.com/help?a=1&b=2"}]}]}}`, "https://accounts.google.com/help?a=1&b=2"},
|
|
{`{"error":{"details":[{"reason":"VALIDATION_REQUIRED","metadata":{"validation_link":"https://accounts.google.com/l","validation_url":"https://accounts.google.com/u"}}]}}`, "https://accounts.google.com/l"},
|
|
{`{"error":{"details":[{"reason":"VALIDATION_REQUIRED","metadata":{"validation_url":"https://accounts.google.com/u","retry":3}}]}}`, "https://accounts.google.com/u"},
|
|
{`{"error":{"details":[{"reason":"VALIDATION_REQUIRED","metadata":{}},{"links":[{"description":"More","url":"https://support.google.com/x"}]}]}}`, ""},
|
|
} {
|
|
if link, ok := Verification([]byte(c.body)); !ok || link != c.want {
|
|
t.Fatalf("%s: %q %v", c.body, link, ok)
|
|
}
|
|
}
|
|
}
|