Reduce Sentry noise in application password login flow#22846
Conversation
Fixes Sentry WORDPRESS-ANDROID-3F8C, WORDPRESS-ANDROID-3F8H, WORDPRESS-ANDROID-3F8J, and WORDPRESS-ANDROID-3F8P. All four issues are non-fatal reports from the application password login flow that fire on user-recoverable failures (network, auth, transient SiteStore errors, cosmetic URL mismatches), drowning out genuine bugs. - Add reportToSentry flag to emitError / logAndEmitSiteChangedError. - Skip Sentry for IOException / DiscoveryException causes in fetchSites. - Skip Sentry for all OnSiteChanged error events; preserve the SiteStore error type in analytics + AppLog instead. - Skip Sentry for site_not_found / no_rows_affected / empty_credentials validation outcomes; keep it for the genuine db_read_exception path. - Reuse ApplicationPasswordLoginHelper.findSiteByUrl in handleSiteChangedSuccess so site_not_found does not fire on cosmetic URL differences (trailing slash, www prefix, scheme). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Generated by 🚫 Danger |
|
|
|
|
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
adalpari
left a comment
There was a problem hiding this comment.
There are two linked reports, that are mentioning the error A_P: site_not_found, but if you look at the code, that error doesn't exist anymore (the noisy one I changed), so I'm not sure those ones are aplicable.
The other ones look legit.
@adalpari I was confused by this so I asked Claude about it and here is the response: I think there's been a mix-up between two different report sites — the A_P: site_not_found format you removed in the earlier cleanup is indeed gone, but 3F8J and 3F8P originate from a different exception: // ApplicationPasswordLoginViewModel.emitError:166 The Sentry titles confirm this — they're Application password login failed: site_not_found and …: site_store_error (no A_P: prefix). When errorMessage happens to be the string site_not_found, the title can look like the old report at a glance. Both issues are still active:
So these aren't already-resolved leftovers — they're the same emitError path firing on validation/SiteStore outcomes that this PR is silencing. |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #22846 +/- ##
=======================================
Coverage 37.21% 37.21%
=======================================
Files 2317 2317
Lines 124536 124549 +13
Branches 16912 16915 +3
=======================================
+ Hits 46340 46352 +12
Misses 74446 74446
- Partials 3750 3751 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Sounds reasonable then. |


Summary
Fixes four noisy non-fatal Sentry reports from the application password login flow:
DiscoveryExceptionfromDiscoveryXMLRPCClient.getResponse(~2.8K events / ~1.1K users)DiscoveryExceptionfromSelfHostedEndpointFinder.discoverXMLRPCEndpoint(~2.2K events / ~900 users)site_not_foundafter a successful site fetch (~1.7K events / ~833 users)site_store_errorfor any SiteStore error (~665 events / ~323 users)All four are user-recoverable failures (network, auth, transient backend errors, cosmetic URL mismatches between callback and stored
SiteModel) that were being routed throughcrashLogging.sendReportWithTag, drowning out genuine bugs in dashboards.What changed
emitError/logAndEmitSiteChangedErrorgain areportToSentryflag.fetchSitesouter catch classifies the cause:IOExceptionandDiscoveryException(anywhere in the cause chain) skip Sentry.handleSiteChangedErroralways skips Sentry; the SiteStore error type is preserved in the existing analytics call (site_changed_failed:<TYPE>) and AppLog.handleSiteChangedSuccess(site_not_found,no_rows_affected,empty_credentials) skip Sentry. The genuinedb_read_exceptionbranch still reports.handleSiteChangedSuccessnow reusesApplicationPasswordLoginHelper.findSiteByUrl(madeinternal) so cosmetic URL differences (trailing slash,www.prefix, scheme) no longer triggersite_not_found.Test plan
:WordPress:testJetpackDebugUnitTest --tests ApplicationPasswordLoginViewModelTest)given onSiteChanged with error, then no Sentry report is sentgiven site_not_found validation, then no Sentry report is sentgiven fetchSites with IOException cause, then no Sentry report is sentgiven onSiteChanged success and site matched via tolerant URL match, then emit success🤖 Generated with Claude Code