Skip to content

Migrate to wordpress-rs 0.8.0 - #23295

Merged
adalpari merged 6 commits into
trunkfrom
adalpari/migrate-wordpress-rs-0.8.0
Sep 4, 2026
Merged

Migrate to wordpress-rs 0.8.0#23295
adalpari merged 6 commits into
trunkfrom
adalpari/migrate-wordpress-rs-0.8.0

Conversation

@adalpari

@adalpari adalpari commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

TL;DR

This PR updates the wordpress-rs library to version 0.8.0

Description

Bumps wordpress-rs from 0.7.0 to 0.8.0 and adapts the app (and its
tests) to the binding's breaking API changes.

Why: 0.8.0 is the first released wordpress-rs that contains the bot
context.sources deserialization fix, which the conversation-screen work in
#23238 depends on. That PR currently pins a temporary PR build of
wordpress-rs because 0.7.0 lacks the fix; this migration unblocks
#23238
, which can then merge trunk and drop the temporary pin.

API changes handled

  • Typed dates:
    • Media, domain and stats date fields are now WpDateString — wrapped on
      the way in (WpDateString(str)) and unwrapped via .value on the way out.
    • Application-password, comment, subscriber and self-hosted-user dates are
      now java.util.Date. Application-password dates are formatted in UTC so
      the displayed day still matches the offset-less timestamp the API reports
      rather than shifting with the device timezone.
  • Locale moved from endpoint params to the client — see below.
  • API discovery: the ApiDiscoveryResult.FailureFetchAndParseApiRoot / FailureFindApiRoot / FailureParseSiteUrl variants collapsed into a single
    ApiDiscoveryResult.Failure(AutoDiscoveryAttemptFailure). The failure-reason
    and message extraction in ApplicationPasswordLoginHelper were rewritten
    against the new shape (AutoDiscoveryAttemptFailure is a Throwable, so its
    message replaces the removed userFacingErrorMessage helper).
  • WpRequestResult.toLogErrorString() removed: domains logging now logs
    the result directly.
  • Media error variants: MediaFileUnreadable / ConnectionError were
    already handled on trunk; no change needed here.

Locale: why StatsInsightsParams disappeared, and how localization is preserved

Two upstream PRs landed between 0.7.0 and 0.8.0:

  • wordpress-rs Crash report 2.9.1: IllegalArgumentException in PostsActivity$deletePostTask.onPostExecute #1590Send a locale query parameter on WordPress.com
    requests
    .
    WP.com localizes a response when the request carries a locale
    query parameter, but the generated request builders never sent one. The
    parameter name depends on the API version (locale for /rest/v1.x,
    _locale for /wpcom/v2, none for /oauth2) and the value is only known
    at runtime, so neither half fits in an endpoint's params type. It now comes
    from a WpComLanguageProvider on the client, asked once per request.
  • wordpress-rs issue/1578-blog-preview-empty-title #1597Remove the per-endpoint locale parameter. With the
    client sending it, the per-endpoint field was redundant: locale was dropped
    from ProductsParams, SitePlansParams and every Stats*Params, and
    StatsInsightsParams / StatsSummaryParams / LanguagesGetParams were
    deleted outright because locale was the only thing they carried (so their
    endpoints no longer take a params argument at all).

That is why this PR removes locale = wpComLanguage from the stats params and
why getStatsInsights / getStatsSummary now take only the site id.

Important: the Kotlin languageProvider is optional and defaults to
null
, so simply deleting the per-endpoint locale would have silently
stopped sending a locale on every WP.com request. WpComApiClientProvider now
supplies one derived from the device locale, which restores localization for
all WP.com requests
— broader than before, when only the stats/products/plans
endpoints carried the parameter themselves. Returning null (an unmappable
locale) sends no locale and leaves the choice to the server, matching the
library's contract.

Other stats changes

Response period fields are now typed value classes, unwrapped via .value.

Testing instructions

This is a dependency migration; correctness is primarily covered by compilation
and the existing unit tests.

  1. Build the app.
  • ./gradlew assembleJetpackDebug succeeds
  • ./gradlew detekt passes
  1. Run the affected unit tests.
  • ApplicationPasswordLoginHelperTest, SiteApiRestUrlRecovererTest,
    EditorSettingsRepositoryTest, CommentsRsDataSourceTest,
    CommentsRsListMappingTest, MediaRsApiRestClientTest pass
  1. Smoke-test the touched features (WP.com + self-hosted): Stats, Domains,
    Comments, Subscribers, Media upload/browse, and Application-password login
    discovery.
  • No regressions in the above
  1. Verify localization still works with a non-English device language.
  • Server-rendered labels (e.g. Stats country/referrer names) come back in
    the device language, confirming the client-level locale is being sent

Notes for reviewers

  • The new-stats changes in StatsDataSourceImpl are the largest surface.
    They are type adaptations (date wrapping, period .value unwrapping, locale
    removal), but the new-stats owners should sanity-check the stats queries
    end-to-end.
  • A couple of newly-nullable dates are given safe fallbacks (comment dateGmt
    → epoch; subscriber "date subscribed" → empty string when absent). Worth a
    look to confirm the fallbacks are acceptable.

Related: unblocks #23238

🤖 Generated with Claude Code

Bump wordpress-rs from 0.7.0 to 0.8.0 and adapt to its breaking API
changes across media, application passwords, application-password login
discovery, comments, domains, new-stats, subscribers and self-hosted
users (plus their tests):

- Date fields are now typed: media/domain/stats dates use WpDateString
  (wrap/unwrap via .value); application-password, comment, subscriber and
  user dates are now java.util.Date.
- API discovery collapsed the Failure* variants into a single
  ApiDiscoveryResult.Failure(AutoDiscoveryAttemptFailure).
- WpRequestResult.toLogErrorString() was removed; log the result directly.
- Stats params dropped the locale argument, getStatsInsights/getStatsSummary
  no longer take a params object, and response periods are typed value
  classes unwrapped via .value.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dangermattic

dangermattic commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator
2 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@wpmobilebot

Copy link
Copy Markdown
Contributor

Project dependencies changes

list
! Upgraded Dependencies
rs.wordpress.api:android:0.8.0, (changed from 0.7.0)
rs.wordpress.api:kotlin:0.8.0, (changed from 0.7.0)
tree
 +--- project :libs:fluxc
-|    \--- rs.wordpress.api:android:0.7.0
-|         +--- com.squareup.okhttp3:okhttp:5.4.0 (*)
-|         +--- com.squareup.okhttp3:okhttp-tls:5.4.0
-|         |    +--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.4.10 (*)
-|         |    +--- com.squareup.okio:okio:3.17.0 (*)
-|         |    \--- com.squareup.okhttp3:okhttp:5.4.0 (*)
-|         +--- net.java.dev.jna:jna:5.19.1
-|         +--- rs.wordpress.api:kotlin:0.7.0
-|         |    +--- com.squareup.okhttp3:okhttp:5.4.0 (*)
-|         |    +--- com.squareup.okhttp3:okhttp-tls:5.4.0 (*)
-|         |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 -> 1.11.0 (*)
-|         |    \--- org.jetbrains.kotlin:kotlin-stdlib:2.3.21 -> 2.4.10 (*)
-|         \--- org.jetbrains.kotlin:kotlin-stdlib:2.3.21 -> 2.4.10 (*)
+|    \--- rs.wordpress.api:android:0.8.0
+|         +--- com.squareup.okhttp3:okhttp:5.4.0 (*)
+|         +--- com.squareup.okhttp3:okhttp-tls:5.4.0
+|         |    +--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.4.10 (*)
+|         |    +--- com.squareup.okio:okio:3.17.0 (*)
+|         |    \--- com.squareup.okhttp3:okhttp:5.4.0 (*)
+|         +--- net.java.dev.jna:jna:5.19.1
+|         +--- rs.wordpress.api:kotlin:0.8.0
+|         |    +--- com.squareup.okhttp3:okhttp:5.4.0 (*)
+|         |    +--- com.squareup.okhttp3:okhttp-tls:5.4.0 (*)
+|         |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 -> 1.11.0 (*)
+|         |    \--- org.jetbrains.kotlin:kotlin-stdlib:2.3.21 -> 2.4.10 (*)
+|         \--- org.jetbrains.kotlin:kotlin-stdlib:2.3.21 -> 2.4.10 (*)
-\--- rs.wordpress.api:android:0.7.0 (*)
+\--- rs.wordpress.api:android:0.8.0 (*)

@wpmobilebot

wpmobilebot commented Sep 4, 2026

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
Versionpr23295-6c049a1
Build Number1498
Application IDcom.jetpack.android.prealpha
Commit6c049a1
Installation URL536euksbit1v0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Sep 4, 2026

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
Versionpr23295-6c049a1
Build Number1498
Application IDorg.wordpress.android.prealpha
Commit6c049a1
Installation URL0ip9elipu82e0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 5.20833% with 91 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.04%. Comparing base (ef380d4) to head (6c049a1).
⚠️ Report is 1 commits behind head on trunk.

Files with missing lines Patch % Lines
...roid/ui/newstats/datasource/StatsDataSourceImpl.kt 0.00% 59 Missing ⚠️
...plicationpassword/ApplicationPasswordsViewModel.kt 0.00% 8 Missing ⚠️
...droid/networking/restapi/WpComApiClientProvider.kt 0.00% 7 Missing ⚠️
...s/android/ui/subscribers/SubscriberDetailScreen.kt 0.00% 4 Missing ⚠️
...ordpress/android/ui/selfhostedusers/SampleUsers.kt 0.00% 3 Missing ⚠️
...ess/android/ui/subscribers/SubscribersViewModel.kt 0.00% 3 Missing ⚠️
...i/accounts/login/ApplicationPasswordLoginHelper.kt 66.66% 1 Missing ⚠️
...ndroid/ui/comments/unified/CommentsRsDataSource.kt 0.00% 0 Missing and 1 partial ⚠️
...s/android/ui/domains/DomainSuggestionsViewModel.kt 50.00% 1 Missing ⚠️
...ui/domains/management/DomainManagementViewModel.kt 0.00% 1 Missing ⚠️
... and 3 more
Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #23295   +/-   ##
=======================================
  Coverage   38.04%   38.04%           
=======================================
  Files        2353     2353           
  Lines      128892   128876   -16     
  Branches    17934    17940    +6     
=======================================
- Hits        49033    49030    -3     
+ Misses      75837    75827   -10     
+ Partials     4022     4019    -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

adalpari and others added 2 commits September 4, 2026 10:56
0.8.0 turned these fields into absolute Dates. Formatting them in the
device timezone could shift the displayed day versus the offset-less
timestamp the API reports, so format in UTC to preserve the previous
behaviour.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
wordpress-rs #1590 moved the locale query parameter off the individual
endpoint params and onto the client, because the parameter name varies by
API version and the value is only known at runtime; #1597 then dropped the
now-redundant per-endpoint locale field. The Kotlin languageProvider is
optional and defaults to null, so without wiring it up we would silently
stop sending a locale on every WP.com request.

Provide it from the device locale, restoring localization for all WP.com
requests rather than only the stats/products/plans endpoints that used to
carry the parameter themselves.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@adalpari
adalpari marked this pull request as ready for review September 4, 2026 09:15
@adalpari
adalpari requested a review from a team as a code owner September 4, 2026 09:15
@adalpari
adalpari requested review from nbradbury and removed request for a team September 4, 2026 09:15
@nbradbury

Copy link
Copy Markdown
Contributor

I'm not sure any of these are real issues, but worth a look.

review-pr23295-wordpress-rs-080-2026-09-04.pdf

Three fixes from the PR review of the 0.8.0 migration:

- Self-hosted login rendered a raw Throwable message, an internal dump of
  the discovery attempt. 0.8.0 replaced userFacingErrorMessage() with
  localizedDescription(), which returns a translated sentence; use it, and
  correct the comment that claimed there was no replacement.
- Logging the WpRequestResult directly printed its data-class toString(),
  which includes the raw response body -- exactly what the removed
  toLogErrorString() existed to omit. Pass a WpRequestErrorLogger using the
  library's default redaction policy to WpComApiClientProvider so every
  consumer gets it, and drop the interpolated result from the call sites.
- The subscribers list fell back to Instant.EPOCH for a missing
  dateSubscribed, rendering as 1970. Fall back to an empty string, matching
  the other null-date sites in this migration.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@adalpari

adalpari commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

I'm not sure any of these are real issues, but worth a look.

review-pr23295-wordpress-rs-080-2026-09-04.pdf

Some assertions make sense, and I've introduced some changes.

I'm addressing 4 in a different PR because I need to unblock the upgrade, and it's not an introduced problem but an issue with how the clients are initialised.

#4 — not a regression, but it does narrow my commit message’s “all WP.com requests stay localized” claim. Those two use different constructor overloads (interceptors / availability provider), so routing them through the provider likely needs a second provider method — not a one-liner.

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

Looks good! :shipit:

@adalpari
adalpari enabled auto-merge (squash) September 4, 2026 12:50
@adalpari
adalpari merged commit 9fa0185 into trunk Sep 4, 2026
23 checks passed
@adalpari
adalpari deleted the adalpari/migrate-wordpress-rs-0.8.0 branch September 4, 2026 13:03
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