decolua/9router · error · Error
Failed to load code assist: ${errorText}
Error message
Failed to load code assist: ${errorText} What it means
AntigravityService.loadCodeAssist POSTs to the cloudaicompanion loadCodeAssist endpoint with client metadata and throws this on non-2xx, embedding the response body. This call resolves the user's Cloud project ID and tier, so failing here blocks the whole Antigravity onboarding.
Source
Thrown at src/lib/oauth/services/antigravity.js:111
* Uses numeric enum values matching Antigravity binary ClientMetadata.
*/
getMetadata() {
return getOAuthClientMetadata();
}
/**
* Fetch Project ID and Tier from loadCodeAssist API
*/
async loadCodeAssist(accessToken) {
const response = await fetch(this.config.loadCodeAssistEndpoint, {
method: "POST",
headers: this.getApiHeaders(accessToken),
body: JSON.stringify({ metadata: this.getMetadata() }),
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Failed to load code assist: ${errorText}`);
}
const data = await response.json();
// Extract project ID
let projectId = data.cloudaicompanionProject;
if (typeof projectId === 'object' && projectId !== null && projectId.id) {
projectId = projectId.id;
}
// Extract tier ID (default to legacy-tier)
let tierId = "legacy-tier";
if (Array.isArray(data.allowedTiers)) {
for (const tier of data.allowedTiers) {
if (tier.isDefault && tier.id) {
tierId = tier.id.trim();
break;
}View on GitHub (pinned to 90b52e06ff)
Solutions
- Refresh the access token and retry — 401 means the bearer token expired
- Inspect the embedded body: 403 usually means scopes/entitlement; 404 means the endpoint moved
- Update ANTIGRAVITY_CONFIG.loadCodeAssistEndpoint to the current Antigravity API URL
- Ensure getApiHeaders sends the exact loadCodeAssistUserAgent Antigravity expects
- If the project is not yet provisioned, follow up with the onboardUser flow
Example fix
// before
const { projectId } = await svc.loadCodeAssist(staleAccessToken);
// after
const fresh = await refreshAccessToken(refreshToken); // 401 protection
let res;
try { res = await svc.loadCodeAssist(fresh); }
catch (e) {
if (/ 404|Not Found/.test(e.message)) throw new Error('loadCodeAssist endpoint changed — update ANTIGRAVITY_CONFIG');
throw e;
} Defensive patterns
Strategy: retry
Validate before calling
// pre-flight: fresh token
const freshToken = await ensureFreshAccessToken(); // refresh if >55min old
if (!freshToken) throw new Error('No valid Antigravity token — re-run OAuth before loadCodeAssist'); Type guard
const isCodeAssistError = (e) => e instanceof Error && e.message.startsWith('Failed to load code assist:');
const classify = (e) => /\b401\b/.test(e.message) ? 'token-expired'
: /\b403\b/.test(e.message) ? 'no-entitlement'
: /\b404\b/.test(e.message) ? 'endpoint-moved'
: /\b429\b/.test(e.message) ? 'throttled' : 'server-error'; Try / catch
try { const { projectId, tierId } = await svc.loadCodeAssist(token); }
catch (e) {
if (!isCodeAssistError(e)) throw e;
const kind = classify(e);
if (kind === 'token-expired') retryWithRefreshedToken();
else if (kind === 'throttled') await sleep(5000).then(retry);
else throw new Error(`loadCodeAssist ${kind} — ${e.message.slice(0, 120)}`);
} Prevention
- Always refresh the access token before loadCodeAssist if the exchange was >~1h ago
- Monitor the Antigravity endpoint URL — reverse-engineered Google APIs move often
- Send the exact loadCodeAssistUserAgent the client expects
- Handle the not-provisioned case by following up with onboardUser
- Back off on 429 and retry with a fresh token on 401
When it happens
Trigger: Access token expired or lacking required Gemini Code Assist scopes (401/403); the user's Google account has no Code Assist/Gemini project provisioned; loadCodeAssist endpoint URL outdated after a Google-side change; the required loadCodeAssistUserAgent is rejected; 429 quota throttling.
Common situations: Calling loadCodeAssist long after token exchange without refresh; the Antigravity endpoint moved after an upstream update (common with reverse-engineered APIs); the account is not yet onboarded and needs onboardUser first; region not supported.
Related errors
- Token exchange failed: ${error}
- Antigravity API error: ${response.status}
- `Token exchange failed: ${error}`
- `Token exchange failed: ${error}`
- `Windsurf ${path} HTTP ${res.status}: ${text.slice(0, 200)}`
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/5e50f435a0c270cc.
Report an issue: GitHub.