win 12ae97b755 fix: Increase maxOutputTokens in Antigravity test request from 1 to 10
The test request was using maxOutputTokens: 1, which caused Google API to
generate only 1 token. When decoded, this single token produced "It" as the
response, making it look like an error.

Changed:
- Content: "." → "Test connection" (more meaningful prompt)
- MaxTokens: 1 → 10 (enough tokens to verify connection is working)

This fixes the issue where account test always showed "It" in the response,
which was actually just the truncated output from the single-token generation.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-04-11 18:49:53 +08:00

115 lines
3.9 KiB
Go

package main
import (
"context"
"flag"
"fmt"
"log"
"strings"
"time"
"github.com/Wei-Shaw/sub2api/internal/pkg/antigravity"
)
func repeatStr(s string, count int) string {
return strings.Repeat(s, count)
}
func main() {
accessToken := flag.String("token", "", "OAuth access token")
projectID := flag.String("project", "", "Project ID")
proxyURL := flag.String("proxy", "", "Proxy URL (optional)")
flag.Parse()
if *accessToken == "" || *projectID == "" {
log.Fatal("missing required flags: -token and -project")
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
client, err := antigravity.NewClient(*proxyURL)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
fmt.Println(repeatStr("=", 80))
fmt.Println("Antigravity Privacy Setup Diagnostic Test")
fmt.Println(repeatStr("=", 80))
// Step 1: Verify token is valid by fetching user info
fmt.Println("\n[Step 1] Verifying access token...")
userInfo, err := client.GetUserInfo(ctx, *accessToken)
if err != nil {
log.Fatalf("failed to get user info: %v", err)
}
fmt.Printf("✓ Email: %s\n", userInfo.Email)
// Step 2: Call SetUserSettings
fmt.Println("\n[Step 2] Calling SetUserSettings (clear privacy settings)...")
setResp, err := client.SetUserSettings(ctx, *accessToken)
if err != nil {
log.Fatalf("SetUserSettings failed: %v", err)
}
if setResp.IsSuccess() {
fmt.Println("✓ SetUserSettings succeeded")
fmt.Printf(" Response: %+v\n", setResp)
} else {
fmt.Println("✗ SetUserSettings returned non-empty userSettings")
fmt.Printf(" Response: %+v\n", setResp)
fmt.Println("\n ERROR: This indicates privacy settings were NOT cleared!")
fmt.Println(" Possible causes:")
fmt.Println(" 1. Account restrictions on privacy settings")
fmt.Println(" 2. Account still has telemetryEnabled=true")
fmt.Println(" 3. API response indicates settings persist")
}
// Step 3: Verify by calling FetchUserInfo
fmt.Println("\n[Step 3] Calling FetchUserInfo to verify privacy status...")
userInfoResp, err := client.FetchUserInfo(ctx, *accessToken, *projectID)
if err != nil {
log.Fatalf("FetchUserInfo failed: %v", err)
}
if userInfoResp.IsPrivate() {
fmt.Println("✓ Privacy is properly set (userSettings is empty)")
fmt.Printf(" Response: %+v\n", userInfoResp)
} else {
fmt.Println("✗ Privacy is NOT properly set (userSettings contains telemetryEnabled)")
fmt.Printf(" Response: %+v\n", userInfoResp)
fmt.Println("\n ERROR: This explains the 503 errors in gateway!")
fmt.Println(" Reason: Antigravity API rejects requests from accounts with")
fmt.Println(" telemetryEnabled=true to protect user privacy")
}
// Summary
fmt.Println("\n" + repeatStr("=", 80))
fmt.Println("DIAGNOSIS SUMMARY")
fmt.Println(repeatStr("=", 80))
if setResp.IsSuccess() && userInfoResp.IsPrivate() {
fmt.Println("✓ Privacy setup is SUCCESSFUL")
fmt.Println(" This account should NOT experience 503 errors due to privacy")
fmt.Println(" The 503 errors might be due to:")
fmt.Println(" 1. Temporary API outages")
fmt.Println(" 2. Rate limiting on new accounts")
fmt.Println(" 3. Other infrastructure issues")
} else if !setResp.IsSuccess() && !userInfoResp.IsPrivate() {
fmt.Println("✗ Privacy setup FAILED")
fmt.Println(" The account cannot clear privacy settings on Antigravity")
fmt.Println(" This causes the 503 Service Unavailable errors")
fmt.Println("\nSOLUTION:")
fmt.Println(" 1. Check if this is a restricted account type")
fmt.Println(" 2. Try re-authorizing the account")
fmt.Println(" 3. Check Antigravity API rate limiting")
fmt.Println(" 4. Inspect firewall/proxy settings")
} else {
fmt.Println("⚠ INCONSISTENT STATE:")
fmt.Println(" SetUserSettings and FetchUserInfo returned different results")
fmt.Println(" This might indicate a transient API issue or data sync delay")
}
fmt.Println("\n" + repeatStr("=", 80))
}