fix: data race, token file misplacement, and silent auth errors#170
fix: data race, token file misplacement, and silent auth errors#170iamMrGaurav wants to merge 2 commits intoUse-Tusk:mainfrom
Conversation
iamMrGaurav
commented
Feb 14, 2026
- Guard Executor.cancelTests with a mutex to eliminate the data race between RunTestsConcurrently and the signal-handler CancelTests path
- Return error from NewAuthenticator when os.UserConfigDir() fails, preventing auth tokens from being written to the current working directory instead of ~/.config/tusk/
- Propagate io.ReadAll errors in all four Auth0 HTTP response paths (device code, token poll, userinfo, refresh) instead of silently continuing with a partial body
- Guard Executor.cancelTests with a mutex to eliminate the data race
between RunTestsConcurrently and the signal-handler CancelTests path
- Return error from NewAuthenticator when os.UserConfigDir() fails,
preventing auth tokens from being written to the current working
directory instead of ~/.config/tusk/
- Propagate io.ReadAll errors in all four Auth0 HTTP response paths
(device code, token poll, userinfo, refresh) instead of silently
continuing with a partial body
|
@sohil-kshirsagar Please review :) |
|
@iamMrGaurav Thanks for the contribution. The fixes look reasonable, but before we can merge we need reproducible evidence for each bug claim. Could you please add:
We’ll keep this open while you add that context; if there’s no follow-up in 7 days, we’ll close and can revisit once repro/tests are available. |
|
Please let me know if i should remove the test files later, Below are the reproducible steps as follows :
RunTestsConcurrently writes e.cancelTests while a signal-handler goroutine reads and invokes it via CancelTests() — no synchronisation on the $ go test -race ./internal/runner/ -run "TestExecutor_CancelTests" -v -count=1 === RUN TestExecutor_CancelTests_NoDataRace Without the cancelTestsMu sync.Mutex added in this PR, the race detector flags a DATA RACE on e.cancelTests between these two goroutines.
The old code was cfgDir, _ := os.UserConfigDir(). When that call fails (e.g. $HOME unset in a restricted/container environment), cfgDir is "" and TestNewAuthenticator_UserConfigDirFailure clears $HOME / $XDG_CONFIG_HOME to reproduce this, and asserts NewAuthenticator now returns an explicit
All four Auth0 HTTP methods (RequestDeviceCode, PollForToken, FetchUserEmail, refreshAccessToken) had body, _ := io.ReadAll(resp.Body). A Each method now has a dedicated regression test using a custom transport whose response body errors immediately on Read: $ go test -race ./internal/auth/ -v -count=1 === RUN TestNewAuthenticator_UserConfigDirFailure @jy-tan Please review :) |
|
@jy-tan hey, please let me know if there is any update on this ? |