Skip to content

Fix app-password login aborting when apiRootUrl was recovered - #23132

Merged
adalpari merged 2 commits into
trunkfrom
adalpari/app-password-empty-fetch-params
Jul 22, 2026
Merged

Fix app-password login aborting when apiRootUrl was recovered#23132
adalpari merged 2 commits into
trunkfrom
adalpari/app-password-empty-fetch-params

Conversation

@adalpari

@adalpari adalpari commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes application-password logins that were silently aborting with empty_fetch_params,
which was also being reported to Sentry as if it were a crash.

Root cause (functional bug): fetchSites is only reached from the SiteNotFound
branch, which means the credentials already passed the non-empty validation inside
storeApplicationPasswordCredentialsFrom. The empty param was the apiRootUrl: when it
was missing from the callback (cache miss — e.g. the process was killed between discovery
and the auth callback), the helper recovered it via fallback discovery into a local
effectiveUrlLogin. But StoreCredentialsResult.SiteNotFound carried no data, so the
ViewModel fell back to the original urlLogin whose apiRootUrl was still empty →
fetchSites saw an empty param and aborted an otherwise-valid login.

Sentry noise: the empty_fetch_params failure built a synthetic
Exception("Application password login failed: empty_fetch_params") purely to file a
Sentry report. It's a user-recoverable data condition (still logged + tracked via
analytics), not a bug — consistent with how site_store_error and the validation cases
are already handled in this file.

Changes

  • ApplicationPasswordLoginHelper: SiteNotFound is now
    data class SiteNotFound(val urlLogin: UriLogin) and returns the effective login with
    the recovered apiRootUrl.
  • ApplicationPasswordLoginViewModel: the SiteNotFound branch fetches with the
    recovered login; the empty_fetch_params error now passes reportToSentry = false.
  • Tests: updated existing SiteNotFound stubs and added regression coverage for the
    recovered-apiRootUrl propagation (helper + ViewModel) and for empty_fetch_params
    not hitting Sentry.

Testing instructions

  1. On a fresh install (no prior discovery cache), log into a self-hosted site using
    application-password authentication that requires REST API discovery.
  2. Complete the authorization on the WordPress consent page.
  • Verify the site is added successfully and no empty_fetch_params error appears

🤖 Generated with Claude Code

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>
@dangermattic

dangermattic commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

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>
@adalpari
adalpari marked this pull request as ready for review July 22, 2026 11:32
@wpmobilebot

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr23132-1640394
Build Number1498
Application IDcom.jetpack.android.prealpha
Commit1640394
Installation URL3pmaae0p9gsa8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr23132-1640394
Build Number1498
Application IDorg.wordpress.android.prealpha
Commit1640394
Installation URL23vrlqvff9j38
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@adalpari
adalpari requested a review from nbradbury July 22, 2026 11:33

@nbradbury nbradbury left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@adalpari
adalpari merged commit 63ecadd into trunk Jul 22, 2026
24 checks passed
@adalpari
adalpari deleted the adalpari/app-password-empty-fetch-params branch July 22, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants