Fix false connectivity banner on private Atomic sites#22926
Conversation
|
|
|
|
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
85cf367 to
b964f35
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release/26.8 #22926 +/- ##
================================================
+ Coverage 37.33% 37.34% +0.01%
================================================
Files 2319 2320 +1
Lines 124674 124714 +40
Branches 16951 16959 +8
================================================
+ Hits 46551 46580 +29
- Misses 74361 74370 +9
- Partials 3762 3764 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Editor capability detection on Atomic sites probes the direct host via unauthenticated REST API discovery (added in #22883). Private Atomic hosts gate anonymous requests, so discovery fails and the My Site "Unable to connect to your site" banner appears even though the site is reachable. Fall back to an authenticated app-password probe against the same host when discovery fails and credentials exist.
b964f35 to
fd57211
Compare
|
@jkmassel I still see this banner immediately after logging in.
However, the banner disappears if I pull-to-refresh. |
|
@jkmassel Claude identified this as a minor issue worth resolving before merging:
|
The authenticated app-password fallback previously returned a silent `false` on a non-success response, and the no-credentials path was also silent. Log both (mirroring the discovery-failure log) so a recurrence of the connectivity banner can be diagnosed from AppLog rather than being indistinguishable from "discovery failed, no creds".
Addressed by bf2142e |
On first login an Atomic site's application password is minted asynchronously on the My Site screen, so the connectivity capability fetch can race ahead of it and fail purely for lack of credentials — flashing a false "unable to connect" banner that clears on the next refresh. Treat a credential-less fetch as pending rather than a connection failure, mirroring the existing offline suppression; the application-password card already owns the no-credentials state.
The connectivity banner's capability fetch and the application-password mint both run on the My Site screen with no ordering, so on first login the fetch loses the race and capability flags aren't detected until the next resume/refresh. Add an app-scoped CredentialsChangedNotifier that both credential-establishment paths (headless mint and interactive login) emit to, and have the connectivity slice re-run detection on it — re-reading a fresh site so it observes the just-persisted credentials. This also closes the asymmetry where only the interactive path announced credential changes globally.
The four-way suppression condition tripped detekt's ComplexCondition threshold once the pending-credentials term was added. Lift it into a named `suppressBanner` flag — clearer intent, and out of the if-condition detekt inspects. No behavior change.
This was a race between the application password being created and the checks happening. It's fixed by 3a10158 and ce19bee. You can test this by logging out of the app entirely, then logging back in and choosing that site - you shouldn't see the banner. |
|
@jkmassel This is working for me and I'll approve it, but you may want to address this comment from Claude: PR description contradicts the implementation. The "Out of scope" section says: ▎ Atomic sites with no app-password credentials whose host blocks anonymous discovery still surface the banner But
|




Description
Fixes a regression where the My Site "Unable to connect to your site" banner appears for private WP.com Atomic sites even though the site is fully reachable. Introduced by #22883 (present in both
trunkandrelease/26.8).There's a narrow case where this fix doesn't work:
/wp-jsonThis is caused by #22905.
Root cause
The banner is driven by
EditorSettingsRepository.fetchEditorCapabilitiesForSite(), which runs two probes and requires both to pass. For Atomic sites the route-support probe was changed in #22883 to run REST API autodiscovery against the site's own host instead of the WP.com proxy:WpLoginClientis the login-flow client — it's constructed with no credentials (ApplicationModule.provideWpLoginClient), so that discovery call is unauthenticated. A private Atomic site gates anonymous requests to its host, so discovery fails (FailureFetchAndParseApiRoot), the route probe returnsfalse, and the banner renders — even though the proxy-backed theme probe in the same fetch succeeds.Confirmed on device against a private Atomic site, where a single refresh shows the failure is specifically the unauthenticated probe:
FailureFetchAndParseApiRootFix
When direct-host discovery fails and the site has application-password credentials, fall back to an authenticated probe against the same direct host using the app-password (Basic auth) client — the transport the editor actually uses on Atomic. Routes are read from
apiRoot().get()and resolved against the direct host, mirroringfetchRouteSupportViaConfiguredClientbut bypassing the WP.com proxy. Public Atomic sites are unchanged (discovery still succeeds on the first try); sites without app-password credentials are unchanged (nothing to authenticate with → failure, as before).Verified on-device: after the fix the banner no longer appears on a private Atomic site — discovery still fails, the authenticated probe succeeds, and capability detection completes.
EditorSettingsRepository:fetchRouteSupportViaDirectHostDiscoveryfalls back to a newfetchRouteSupportViaApplicationPasswordClientwhen discovery fails andhasApplicationPasswordCredentials()is true.WpApiClientProvider: addsgetDirectHostApiUrlResolver(site)— the resolver counterpart togetApplicationPasswordClient, so routes fetched through that client resolve against the host they came from.What we explored
/wp-json" robustness for the common case.Out of scope
The deeper issue — a user-facing "site unreachable" banner being driven by an editor-capability probe on a different transport — is left as a follow-up. Atomic sites with no app-password credentials whose host blocks anonymous discovery still surface the banner; there's no credential to authenticate the probe with.
Testing instructions
Private Atomic site (the regression):
Public Atomic site (regression check):
automatticwidgets.wpcomstaging.com).Simple site (regression check):
Unit tests:
./gradlew :WordPress:testJetpackDebugUnitTest --tests EditorSettingsRepositoryTest— 11 pass (9 existing + 2 new covering the authenticated fallback).