fix: correct API key empty validation logic

The condition '!apiKey.trim() && apiKey.length > 1' was always false because
if apiKey.trim() is falsy (empty string), then apiKey.length is 0, which is
not greater than 1. The fix simplifies the check to just '!apiKey.trim()'
to properly validate that the API key is not empty or whitespace-only.
This commit is contained in:
iiitutu 2026-04-13 09:53:02 +08:00
parent 0179726222
commit df120d0f5c

View file

@ -873,10 +873,8 @@ Logging in with Google... Restarting Gemini CLI to continue.
async (apiKey: string) => {
try {
onAuthError(null);
if (!apiKey.trim() && apiKey.length > 1) {
onAuthError(
'API key cannot be empty string with length greater than 1.',
);
if (!apiKey.trim()) {
onAuthError('API key cannot be empty.');
return;
}