Repository navigation
fix: improve auth mutex error handling to prevent crashes - #3339
ChrisWiles wants to merge 2 commits into
Conversation
Fixed three critical issues in auth.rs where mutex lock failures were handled incorrectly: 1. refresh_token() silently ignored lock failures, causing inconsistent state between file and in-memory cache 2. get_token_data() used unwrap() on mutex lock, causing panics 3. get_current_auth_json() used unwrap() on mutex lock, causing panics These functions handle authentication tokens, so failures could crash the application or leave users in inconsistent auth states. Changes: - Functions returning Result now return errors on lock failure - Functions returning Option return None and log errors gracefully - Added test to verify normal mutex behavior still works
|
Thanks for the contribution, and apologies for the slow response. We've received a lot of PRs, and we've fallen behind in reviewing them. Is there a bug report associated with this PR? We generally want to have a bug report associated with each PR. This helps us track, prioritize, and do risk assessment. Does this PR fix a behavioral problem that you or other users are seeing, or is it purely a code robustness improvement? The underlying code has changed a bit since you posted the PR. Could you resolve the merge conflicts? |
|
@ChrisWiles have you seen this happen in the wild? If this is happening in the wild, then it implies a bug in our business logic. This change would potentially sweep that issue under the rug. |
|
This does not appear to be an appropriate fix: closing. |
Summary
Fixes mutex error handling in auth functions that could crash the application.
The Problem
Three auth functions used
.unwrap()on mutex locks, which crashes the program if the mutex is poisoned (happens when a thread panics while holding the mutex):Since these handle authentication tokens, crashes could happen during normal auth operations.
The Fix
Resultnow return errors instead of crashingOptionreturnNoneand log errors gracefullyTests
Added test to verify normal mutex behavior still works correctly.