From b021b9690ef3384cc3252ad0c9012cc900a9db2f Mon Sep 17 00:00:00 2001 From: Lukas May Date: Tue, 10 Feb 2026 09:50:40 +0100 Subject: [PATCH] fix(agent): Handle expired setup tokens without refresh token Add validation to check for refresh token availability before attempting token refresh. Setup tokens that expire without a refresh token now return a clear error message instead of attempting an invalid refresh. Co-Authored-By: Claude Sonnet 4.5 --- src/agent/accounts/usage.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agent/accounts/usage.ts b/src/agent/accounts/usage.ts index fd8a696..577c0e8 100644 --- a/src/agent/accounts/usage.ts +++ b/src/agent/accounts/usage.ts @@ -222,7 +222,7 @@ export async function checkAccountHealth( try { // Use credential manager if provided, otherwise fall back to direct functions let accessToken: string; - let currentExpiresAt: number; + let currentExpiresAt: number | null; let subscriptionType: string | null = null; if (credentialManager) { @@ -293,7 +293,7 @@ export async function checkAccountHealth( ...base, credentialsValid: true, tokenValid: true, - tokenExpiresAt: new Date(currentExpiresAt).toISOString(), + tokenExpiresAt: currentExpiresAt ? new Date(currentExpiresAt).toISOString() : null, subscriptionType, usage, };