fix: use allowedTiers only for onboarding (not paidTier)

paidTier values like g1-pro-tier and g1-ultra-tier are rejected by
the onboardUser API with 400 INVALID_ARGUMENT. This matches the
opencode-antigravity-auth reference which only uses allowedTiers.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Badri Narayanan S
2026-01-19 20:19:40 +05:30
parent 2175118f9f
commit b0c3a61130

View File

@@ -220,17 +220,13 @@ export async function discoverProject(token, projectId = undefined) {
let gotSuccessfulResponse = false; let gotSuccessfulResponse = false;
let loadCodeAssistData = null; let loadCodeAssistData = null;
// Build metadata matching reference: only set duetProject if projectId is truthy
// For loadCodeAssist, reference passes projectId ?? fallbackProjectId
// Reference: opencode-antigravity-auth/src/plugin/project.ts buildMetadata()
const projectIdForLoad = projectId ?? DEFAULT_PROJECT_ID;
const metadata = { const metadata = {
ideType: 'IDE_UNSPECIFIED', ideType: 'IDE_UNSPECIFIED',
platform: 'PLATFORM_UNSPECIFIED', platform: 'PLATFORM_UNSPECIFIED',
pluginType: 'GEMINI' pluginType: 'GEMINI'
}; };
if (projectIdForLoad) { if (projectId) {
metadata.duetProject = projectIdForLoad; metadata.duetProject = projectId;
} }
for (const endpoint of LOAD_CODE_ASSIST_ENDPOINTS) { for (const endpoint of LOAD_CODE_ASSIST_ENDPOINTS) {
@@ -282,23 +278,11 @@ export async function discoverProject(token, projectId = undefined) {
// If we got a successful response but no project, try onboarding // If we got a successful response but no project, try onboarding
if (gotSuccessfulResponse && loadCodeAssistData) { if (gotSuccessfulResponse && loadCodeAssistData) {
// Priority: paidTier > currentTier > allowedTiers (consistent with model-api.js) // Only use allowedTiers for onboarding (matching opencode-antigravity-auth and oauth.js)
let tierId = null; // Note: paidTier (g1-pro-tier, g1-ultra-tier) is NOT valid for onboardUser API
let tierSource = null; // The paidTier is used for subscription detection only, not for onboarding
const tierId = getDefaultTierId(loadCodeAssistData.allowedTiers) || 'free-tier';
if (loadCodeAssistData.paidTier?.id) { logger.info(`[AccountManager] Onboarding user with tier: ${tierId}`);
tierId = loadCodeAssistData.paidTier.id;
tierSource = 'paidTier';
} else if (loadCodeAssistData.currentTier?.id) {
tierId = loadCodeAssistData.currentTier.id;
tierSource = 'currentTier';
} else {
tierId = getDefaultTierId(loadCodeAssistData.allowedTiers);
tierSource = 'allowedTiers';
}
tierId = tierId || 'free-tier';
logger.info(`[AccountManager] Onboarding user with tier: ${tierId} (source: ${tierSource})`);
// Pass projectId for metadata.duetProject (without fallback, matching reference) // Pass projectId for metadata.duetProject (without fallback, matching reference)
// Reference: opencode-antigravity-auth passes parts.projectId (not fallback) to onboardManagedProject // Reference: opencode-antigravity-auth passes parts.projectId (not fallback) to onboardManagedProject