Skip to content

fix(auth): shouldRefreshToken never refreshed a credential with no stored expiresAt (#792) - #793

Merged
developer-ainative merged 1 commit into
mainfrom
fix/issue-792-token-refresh-undefined-expiresat
Sep 16, 2026
Merged

developer-ainative merged 1 commit into
mainfrom
fix/issue-792-token-refresh-undefined-expiresat

Conversation

@developer-ainative

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • New dedicated test file __tests__/lib/auth/tokenRefresh.test.ts (4 tests) — confirmed the core regression-guard assertion genuinely fails against the pre-fix return false code before finalizing the fix
  • npx tsc --noEmit — clean
  • npx vitest run — full suite: 5631 passed, 0 failed

…ored expiresAt (#792)

A credential row with no expiresAt at all (every row captured before the
#443/#664 fix started populating it) made shouldRefreshToken(undefined)
return false — treated as an eternal token, never proactively refreshed no
matter how stale. Confirmed live while investigating #778: Fieldko's stored
zerocrm credential was genuinely dead (core's /api/v1/auth/me returned 401
AUTH_TOKEN_INVALID) yet resolveFounderCredential happily returned it as
valid because shouldRefreshToken(undefined) said no refresh was needed.

A missing expiresAt means "we don't know", not "assume forever" — flip the
default to assume a refresh is needed, matching the same conservative
philosophy provision/route.ts already uses for its own missing-expires_in
fallback. Both real call sites checked safe: auth.ts guards its call behind
an expiresAt truthy check (unreachable branch there), and
primitive-credentials.ts already degrades gracefully when no refresh token
was ever captured either.
@developer-ainative
developer-ainative merged commit d8d9735 into main Sep 16, 2026
1 check passed
@developer-ainative
developer-ainative deleted the fix/issue-792-token-refresh-undefined-expiresat branch September 16, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant