Skip to content

Conversation

@AlexisMora
Copy link
Contributor

@AlexisMora AlexisMora commented Dec 29, 2025

What is Changed / Added

AuthService.getAuthDetails now properly handles the case where the backend detects an old token version during the call to refreshUserToken. When this specific error occurs, the system automatically clears the stored user credentials and throws a dedicated OldTokenDetectedError. This change aims to prevents users from getting stuck in a broken authentication state where their local token is no longer valid on the server.

In the following trace you can see the error I am trying to fix with this pull request

{
  "level": "error",
  "message": "[REPORTED_ERROR]: Old token version detected\nProperties => {\n  \"command\": \"webdav\"\n}\nStack => Error: Old token version detected\n    at new AppError (/usr/lib/node_modules/@internxt/cli/node_modules/@internxt/sdk/dist/shared/types/errors.js:21:28)\n    at HttpClient.normalizeError (/usr/lib/node_modules/@internxt/cli/node_modules/@internxt/sdk/dist/shared/http/client.js:190:15)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async Axios.request (/usr/lib/node_modules/@internxt/cli/node_modules/axios/dist/node/axios.cjs:4478:14)\n    at async AuthService.refreshUserToken (/usr/lib/node_modules/@internxt/cli/dist/services/auth.service.js:79:26)\n    at async AuthService.getAuthDetails (/usr/lib/node_modules/@internxt/cli/dist/services/auth.service.js:54:26)\n    at async Webdav.run"
}

The method in charge of validating and checking the expiration of the token validateTokenAndCheckExpiration was refactored to separate concerns more clearly. This way it is easier to test and reason about token states throughout the authentication flow.

Two new error detection utilities isFileNotFoundError and isOldTokenError were added to identify file system errors and old token errors more reliably.

ConfigService.clearUser was also updated to gracefully handle cases where the credentials file doesn't exist during cleanup operations.

@AlexisMora AlexisMora marked this pull request as ready for review December 29, 2025 15:19
@AlexisMora AlexisMora changed the title refactor: validateTokenAndCheckExpiration simplified and added tests [PB-5305]: validateTokenAndCheckExpiration simplified and added tests Jan 5, 2026
@larryrider
Copy link
Contributor

check sonarcloud issues

Copy link
Contributor

@larryrider larryrider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check sonarcloud issue

@sonarqubecloud
Copy link

@AlexisMora AlexisMora merged commit 06651c7 into main Jan 12, 2026
9 checks passed
@AlexisMora AlexisMora deleted the feat/pb-5305-old-token-version-detected branch January 12, 2026 11:28
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.

3 participants