Migrate to wordpress-rs 0.8.0 - #23295
Conversation
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>
Generated by 🚫 Danger |
Project dependencies changeslist! 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 (*) |
|
|
|
|
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
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>
|
I'm not sure any of these are real issues, but worth a look. |
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>
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.
|


TL;DR
This PR updates the wordpress-rs library to version 0.8.0
Description
Bumps
wordpress-rsfrom0.7.0to0.8.0and adapts the app (and itstests) to the binding's breaking API changes.
Why:
0.8.0is the first releasedwordpress-rsthat contains the botcontext.sourcesdeserialization fix, which the conversation-screen work in#23238 depends on. That PR currently pins a temporary PR build of
wordpress-rsbecause0.7.0lacks the fix; this migration unblocks#23238, which can then merge trunk and drop the temporary pin.
API changes handled
WpDateString— wrapped onthe way in (
WpDateString(str)) and unwrapped via.valueon the way out.now
java.util.Date. Application-password dates are formatted in UTC sothe displayed day still matches the offset-less timestamp the API reports
rather than shifting with the device timezone.
ApiDiscoveryResult.FailureFetchAndParseApiRoot / FailureFindApiRoot / FailureParseSiteUrlvariants collapsed into a singleApiDiscoveryResult.Failure(AutoDiscoveryAttemptFailure). The failure-reasonand message extraction in
ApplicationPasswordLoginHelperwere rewrittenagainst the new shape (
AutoDiscoveryAttemptFailureis aThrowable, so itsmessagereplaces the removeduserFacingErrorMessagehelper).WpRequestResult.toLogErrorString()removed: domains logging now logsthe result directly.
MediaFileUnreadable/ConnectionErrorwerealready handled on trunk; no change needed here.
Locale: why
StatsInsightsParamsdisappeared, and how localization is preservedTwo upstream PRs landed between
0.7.0and0.8.0: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 (
localefor/rest/v1.x,_localefor/wpcom/v2, none for/oauth2) and the value is only knownat runtime, so neither half fits in an endpoint's params type. It now comes
from a
WpComLanguageProvideron the client, asked once per request.client sending it, the per-endpoint field was redundant:
localewas droppedfrom
ProductsParams,SitePlansParamsand everyStats*Params, andStatsInsightsParams/StatsSummaryParams/LanguagesGetParamsweredeleted outright because locale was the only thing they carried (so their
endpoints no longer take a
paramsargument at all).That is why this PR removes
locale = wpComLanguagefrom the stats params andwhy
getStatsInsights/getStatsSummarynow take only the site id.Important: the Kotlin
languageProvideris optional and defaults tonull, so simply deleting the per-endpointlocalewould have silentlystopped sending a locale on every WP.com request.
WpComApiClientProvidernowsupplies 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 unmappablelocale) 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.
./gradlew assembleJetpackDebugsucceeds./gradlew detektpassesApplicationPasswordLoginHelperTest,SiteApiRestUrlRecovererTest,EditorSettingsRepositoryTest,CommentsRsDataSourceTest,CommentsRsListMappingTest,MediaRsApiRestClientTestpassComments, Subscribers, Media upload/browse, and Application-password login
discovery.
the device language, confirming the client-level locale is being sent
Notes for reviewers
StatsDataSourceImplare the largest surface.They are type adaptations (date wrapping, period
.valueunwrapping,localeremoval), but the new-stats owners should sanity-check the stats queries
end-to-end.
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