Skip to content

fix: Check file exists before recovering sessions

0898677
Select commit
Loading
Failed to load commit list.
Merged

fix: Workaround FileNotFoundException on Android when recovering sessions #5084

fix: Check file exists before recovering sessions
0898677
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden completed Mar 30, 2026 in 2m 32s

1 issue

Medium

FileNotFoundException from provider is never triggered in test - `test/Sentry.Tests/GlobalSessionManagerTests.cs:267-276`

The test TryRecoverPersistedSession_NoSessionFile_LogDebug sets _fixture.PersistedSessionProvider = _ => throw new FileNotFoundException() but this exception is never thrown. In GlobalSessionManager.TryRecoverPersistedSession(), line 154 checks _options.FileSystem.FileExists(filePath) before calling the provider. Since no session is started/persisted, FileExists returns false, the method returns early at line 157 with the debug message, and the provider is never invoked. The test passes coincidentally because the debug message matches, but it doesn't actually test exception handling from the provider.

Also found at:

  • src/Sentry/GlobalSessionManager.cs:204-206
4 skills analyzed
Skill Findings Duration Cost
code-review 0 1m 46s $0.59
find-bugs 1 2m 28s $1.31
gha-security-review 0 23.3s $0.19
security-review 0 55.3s $0.30

Duration: 5m 32s · Tokens: 1.4M in / 19.0k out · Cost: $2.40 (+extraction: $0.00, +merge: $0.00)