Skip to content

fix(antigravity): query quota from the account's forward endpoint - #8979

Merged
Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
SipengXie2024:fix/antigravity-quota-forward-endpoint
Nov 20, 2026
Merged

Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
SipengXie2024:fix/antigravity-quota-forward-endpoint

Conversation

@SipengXie2024

Copy link
Copy Markdown
Contributor

Problem

resolveAntigravityForwardBaseURL(account) routes paid Antigravity accounts (Pro / Ultra) to https://daily-cloudcode-pa.googleapis.com and other accounts to https://cloudcode-pa.googleapis.com (with GATEWAY_ANTIGRAVITY_FORWARD_BASE_URL taking precedence). Model discovery (upstream_models.go) already queries the same endpoint via FetchAvailableModelsFromURL.

AntigravityQuotaFetcher.FetchQuota, however, calls FetchAvailableModels and RetrieveUserQuotaSummary, both of which start from BaseURLs[0] (prod). Because Google tracks prod and daily quota buckets separately and prod returns HTTP 200 with unused buckets, paid accounts serving traffic on daily continuously display 0% utilization in both per-model quotas and 5h/weekly quota groups.

Fixes #8588
Fixes #8850

Change

  • Resolve the account's active forwarding endpoint once via resolveAntigravityForwardBaseURL(account) in AntigravityQuotaFetcher.FetchQuota.
  • Call client.FetchAvailableModelsFromURL and client.RetrieveUserQuotaSummaryFromURL against that endpoint so both per-model quotas and 5h/weekly quota groups match the endpoint serving requests, and failures on the selected endpoint do not silently fall back to reading prod's unrelated 0% buckets.
  • Add unit tests in antigravity_quota_fetcher_test.go covering Ultra / Pro accounts (daily), Free accounts (prod), GATEWAY_ANTIGRAVITY_FORWARD_BASE_URL override, and no fallback to prod when daily fails.

Verification

  • go test -tags=unit -v ./internal/service/ -run 'TestFetchQuota|TestBuildQuotaGroups|TestNormalizeTier|TestClassifyForbiddenType|TestExtractValidationURL' -race
  • go test ./internal/pkg/antigravity/
  • go vet ./internal/service/ ./internal/pkg/antigravity/
  • Verified live on two Ultra accounts: GET /api/v1/admin/accounts/:id/usage?force=true returns the real daily 5h and weekly utilization instead of 0%.

@Wei-Shaw
Wei-Shaw merged commit eb91439 into Wei-Shaw:main Nov 20, 2026
9 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

2 participants