Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit eba0f17

Browse files
authored
Fix sign-off logic, re-enable auth tests (#8201)
Fixes https://linear.app/sourcegraph/issue/CODY-4546/fix-the-flaky-agentsrcunauthedteststs-and-reenabled-it-back Fixes https://linear.app/sourcegraph/issue/QA-760/core-logging-out-from-cody-will-show-the-account-logged-in-again ## Fix authentication race condition and re-enable tests This commit resolves a critical race condition in Cody's authentication signout logic that was causing intermittent authentication failures. The core issue stemmed from the order of operations during the signout process, where multiple asynchronous operations were competing with each other in a way that could leave the authentication system in an inconsistent state. The authentication system previously attempted to simultaneously delete tokens from secret storage, remove endpoints from local storage, and sign out the auth provider. This created a problematic race condition where the configuration resolver could trigger during the cleanup process, potentially causing the system to attempt re-authentication with partially cleared credentials. When the configuration resolver observed changes to local storage during signout, it would immediately try to read authentication data that was in the process of being deleted, leading to unpredictable authentication states. The fix reorders these critical operations to ensure proper sequencing. The auth provider is now signed out first, which immediately resets the internal authentication state including `lastValidatedAndStoredCredentials` and `status` properties. Only after this internal state is completely cleared does the system proceed to delete the stored credentials from both secret storage and local storage. This sequential approach eliminates the race condition by ensuring that any configuration resolver triggers that occur during credential deletion will find a cleanly reset authentication state rather than partially cleared data. With the authentication race condition resolved, this PR re-enables previously skipped authentication tests that were disabled due to flakiness in the Ubuntu 18 GitHub Actions environment and unauthed tests which were skipped in general. I also attempted to fix `'starts up with default endpoint and credentials if they are present in the secure store'` test. It was broken due to `stateless` client secrets store being used previously. Switching it to `client-managed` and fixing some `async` calls 'fixed' the test to the extent that it passes when in recording mode, but still fails in replay mode. I may attempt to fix it later, but I skipped it for now. ## Test plan 1. Install the Cody plugin in your JetBrains environment. 2. Login to any account. 3. Logout from Cody. 4. You should be logged out correctly. <!-- Required. See https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles. -->
1 parent 7ad0086 commit eba0f17

File tree

6 files changed

+987
-763
lines changed

6 files changed

+987
-763
lines changed

agent/recordings/auth_2503977039/recording.har.yaml

Lines changed: 119 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)