Skip to content

Fix nil-sceneId crash on advanced-auth browser callback for pre-scene logins (#4098) - #4122

Merged
brandonpage merged 1 commit into
masterfrom
cherry-pick-4098-nil-sceneid
Aug 5, 2026
Merged

Fix nil-sceneId crash on advanced-auth browser callback for pre-scene logins (#4098)#4122
brandonpage merged 1 commit into
masterfrom
cherry-pick-4098-nil-sceneid

Conversation

@brandonpage

Copy link
Copy Markdown
Contributor

What

Cherry-picks #4098 onto master. Original PR was merged to dev; this brings the same fix to the master branch.

Fixes a crash on the advanced-authentication browser callback for logins that start before any UIScene has connected — i.e. apps that begin login from AppDelegate.didFinishLaunchingWithOptions (hybrid and React Native).

Root cause

When login starts pre-scene, request.scene.session.persistentIdentifier is nil, so SFSDKAuthSession.sceneId was nil. On the ASWebAuthenticationSession completion handler, the SDK built an options dictionary keyed by the scene id (kSFIDPSceneIdKey) and looked the session back up in the authSessions store by that id. A nil key both crashed the dictionary insert and dropped the session from the store.

Fix

  • SFSDKAuthSession.m — synthesize a unique per-session scene id (com.salesforce.mobilesdk.unscopedAuthSession-<UUID>) when no scene is connected.
  • SFOAuthCoordinator.m / +Internal.h — extract option-building into -browserCallbackOptionsForSceneId: with a nil guard.
  • SFOAuthCoordinatorTests.m — unit tests covering the scene-less login case.

Testing

  • Cherry-picked the squash-merge commit cleanly onto master; resulting tree is byte-identical to the merged PR. No dev-only dependencies — all referenced symbols exist in the master baseline.
  • SalesforceSDKCore test build succeeded; all 5 SFOAuthCoordinatorTests passed (0 failures), including the 4 new scene-less / nil-guard tests.

Work item

@W-23733618@

… logins (#4098)

Fix nil-sceneId crash on advanced-auth browser callback for pre-scene logins
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
1 Error
🚫 Please re-submit this PR to the dev branch, we may have already fixed your issue.

Generated by 🚫 Danger

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
1 Warning
⚠️ Static Analysis found an issue with one or more files you modified. Please fix the issue(s).

Clang Static Analysis Issues

File Type Category Description Line Col
SFOAuthCoordinator Nullability Memory error nil assigned to a pointer which is expected to have non-null value 120 19
SFOAuthCoordinator Nullability Memory error nil assigned to a pointer which is expected to have non-null value 244 15

Generated by 🚫 Danger

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
TestsPassed ☑️SkippedFailed ❌️
SalesforceSDKCore iOS ^18 Test Results631 ran629 ✅2 ❌
TestResult
SalesforceSDKCore iOS ^18 Test Results
testNonCallbackURL()❌ failure
SFUserAccountManagerTests.testUserAccountEncoding❌ failure

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.85%. Comparing base (e816664) to head (17a2623).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...lesforceSDKCore/Classes/OAuth/SFOAuthCoordinator.m 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4122      +/-   ##
==========================================
- Coverage   66.91%   66.85%   -0.07%     
==========================================
  Files         260      260              
  Lines       22533    22536       +3     
==========================================
- Hits        15079    15066      -13     
- Misses       7454     7470      +16     
Components Coverage Δ
Analytics 70.78% <ø> (ø)
Common 69.56% <ø> (-0.19%) ⬇️
Core 59.64% <83.33%> (-0.09%) ⬇️
SmartStore 74.70% <ø> (ø)
MobileSync 87.41% <ø> (ø)
Files with missing lines Coverage Δ
...SalesforceSDKCore/Classes/OAuth/SFSDKAuthSession.m 91.42% <100.00%> (ø)
...lesforceSDKCore/Classes/OAuth/SFOAuthCoordinator.m 51.80% <66.66%> (+0.14%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
TestsPassed ✅SkippedFailed
AuthFlowTester UI Test Results all1 ran1 ✅
TestResult
No test annotations available

@brandonpage
brandonpage merged commit c7160fd into master Aug 5, 2026
21 of 24 checks passed
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.

2 participants