Fix: Reset invalid accounts on startup and improve project discovery logging
Fixes #33 - Accounts marked as invalid were permanently stuck because
the isInvalid flag was persisted to disk but never reset on startup.
Changes:
- Reset isInvalid flag for all accounts on server startup, giving them
a fresh chance to refresh their OAuth tokens
- Add logging for project discovery failures (was silently failing)
- Add success logging when project is discovered
- Add warning message when falling back to default project
Bug introduced in 01cda83 (2025-12-25) when isInvalid persistence was
added without corresponding reset logic on load.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -123,14 +123,20 @@ export async function discoverProject(token) {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) continue;
|
if (!response.ok) {
|
||||||
|
const errorText = await response.text();
|
||||||
|
logger.warn(`[AccountManager] Project discovery failed at ${endpoint}: ${response.status} - ${errorText}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (typeof data.cloudaicompanionProject === 'string') {
|
if (typeof data.cloudaicompanionProject === 'string') {
|
||||||
|
logger.success(`[AccountManager] Discovered project: ${data.cloudaicompanionProject}`);
|
||||||
return data.cloudaicompanionProject;
|
return data.cloudaicompanionProject;
|
||||||
}
|
}
|
||||||
if (data.cloudaicompanionProject?.id) {
|
if (data.cloudaicompanionProject?.id) {
|
||||||
|
logger.success(`[AccountManager] Discovered project: ${data.cloudaicompanionProject.id}`);
|
||||||
return data.cloudaicompanionProject.id;
|
return data.cloudaicompanionProject.id;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -138,7 +144,8 @@ export async function discoverProject(token) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`[AccountManager] Using default project: ${DEFAULT_PROJECT_ID}`);
|
logger.warn(`[AccountManager] Project discovery failed for all endpoints. Using default project: ${DEFAULT_PROJECT_ID}`);
|
||||||
|
logger.warn(`[AccountManager] If you see 404 errors, your account may not have Gemini Code Assist enabled.`);
|
||||||
return DEFAULT_PROJECT_ID;
|
return DEFAULT_PROJECT_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ export async function loadAccounts(configPath = ACCOUNT_CONFIG_PATH) {
|
|||||||
...acc,
|
...acc,
|
||||||
isRateLimited: acc.isRateLimited || false,
|
isRateLimited: acc.isRateLimited || false,
|
||||||
rateLimitResetTime: acc.rateLimitResetTime || null,
|
rateLimitResetTime: acc.rateLimitResetTime || null,
|
||||||
lastUsed: acc.lastUsed || null
|
lastUsed: acc.lastUsed || null,
|
||||||
|
// Reset invalid flag on startup - give accounts a fresh chance to refresh
|
||||||
|
isInvalid: false,
|
||||||
|
invalidReason: null
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const settings = config.settings || {};
|
const settings = config.settings || {};
|
||||||
|
|||||||
Reference in New Issue
Block a user