You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix app-password login aborting when apiRootUrl was recovered (#23132)
* Fix app-password login aborting when apiRootUrl was recovered
The recovered apiRootUrl was dropped between the helper and the ViewModel,
causing valid logins to fail with empty_fetch_params and file it as a Sentry
bug. Carry the effective login on SiteNotFound and stop reporting the
user-recoverable empty_fetch_params condition to Sentry.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Model reachable empty_fetch_params state in SiteNotFound test
The empty_fetch_params branch is only reachable via an empty-string siteUrl:
storeApplicationPasswordCredentialsFrom rejects an empty apiRootUrl as BadData
before it can return SiteNotFound, but only guards siteUrl against null, so an
empty string slips through to fetchSites. Update the test fixture accordingly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: WordPress/src/main/java/org/wordpress/android/ui/accounts/applicationpassword/ApplicationPasswordLoginViewModel.kt
+12-6Lines changed: 12 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,7 @@ class ApplicationPasswordLoginViewModel @Inject constructor(
89
89
val urlLogin = applicationPasswordLoginHelper.getSiteUrlLoginFromRawData(rawData)
90
90
currentUrlLogin = urlLogin
91
91
// Store credentials if the site already exists
92
-
when (storeCredentials(urlLogin)) {
92
+
when (val storeResult =storeCredentials(urlLogin)) {
93
93
isStoreCredentialsResult.Success-> {
94
94
_onFinishedEvent.emit(
95
95
NavigationActionData(
@@ -102,11 +102,14 @@ class ApplicationPasswordLoginViewModel @Inject constructor(
102
102
}
103
103
isStoreCredentialsResult.SiteNotFound-> {
104
104
waitingForFetchedSite =true
105
+
// Use the effective login returned by the helper: it carries any apiRootUrl
106
+
// recovered via fallback discovery, which the original urlLogin may still lack.
107
+
val effectiveLogin = storeResult.urlLogin
105
108
fetchSites(
106
-
urlLogin.user.orEmpty(),
107
-
urlLogin.password.orEmpty(),
108
-
urlLogin.siteUrl.orEmpty(),
109
-
urlLogin.apiRootUrl.orEmpty()
109
+
effectiveLogin.user.orEmpty(),
110
+
effectiveLogin.password.orEmpty(),
111
+
effectiveLogin.siteUrl.orEmpty(),
112
+
effectiveLogin.apiRootUrl.orEmpty()
110
113
)
111
114
}
112
115
isStoreCredentialsResult.BadData-> {
@@ -186,9 +189,12 @@ class ApplicationPasswordLoginViewModel @Inject constructor(
Copy file name to clipboardExpand all lines: WordPress/src/test/java/org/wordpress/android/ui/accounts/applicationpassword/ApplicationPasswordLoginViewModelTest.kt
+70-9Lines changed: 70 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -201,7 +201,7 @@ class ApplicationPasswordLoginViewModelTest : BaseUnitTest() {
0 commit comments