fix(book-club): review follow-ups — envelope null-data crash, atomic flag, stale-instance gone, slug encoding#18
Conversation
…flag, stale-instance gone, slug encoding
Post-merge review of the Book Club integration surfaced four correctness
issues in the data layer:
- BookClubResult: bookClubCall() mapped a bodiless success ({success:true,
data:null}) to Success(Unit as T) via an unchecked cast, so a data-bearing
endpoint (clubs/clubDetail/dashboard/join) that returned no data crashed the
ViewModel with ClassCastException on res.data. Split into bookClubCall<T>
(null data -> Failure) and bookClubCallUnit (Envelope<Unit> endpoints:
health/propose/vote/rsvp/progress). Removes the cast entirely.
- FeatureStore.setBookClubAvailable(): non-atomic read-modify-write on the
StateFlow could clobber a concurrent flag update. Use _features.update {}.
- BookClubRepository.confirmGone(): returned available==false even when
applyAvailability's instance-switch guard rejected the write, so a stale 404
from a since-switched instance could drive pluginGone on the current screen.
applyAvailability() now reports whether it applied; confirmGone() ANDs it in.
- Routes.clubDetail(): the raw slug was interpolated into the nav route without
URL-encoding. Uri.encode() it (NavType.StringType decodes on receipt).
Verified: :app:compileDebugKotlin passes.
|
Warning Review limit reached
Next review available in: 40 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Post-merge review of the Book Club integration (multi-lens pass over the data + UI layers) surfaced four correctness issues, all in the data layer. Fixed here;
:app:compileDebugKotlinpasses.Fixes
bookClubCall()mapped a bodiless success ({success:true, data:null}) toSuccess(Unit as T)through an unchecked cast, so a data-bearing endpoint (clubs/clubDetail/dashboard/join) returning no data crashed the ViewModel withClassCastExceptiononres.data. Split intobookClubCall<T>(null data → Failure) andbookClubCallUnitfor theEnvelope<Unit>endpoints (health/propose/vote/rsvp/progress). The unchecked cast is gone._features.update { … }.available == falseeven whenapplyAvailability's instance-switch guard rejected the write, so a stale 404 from a since-switched instance could drivepluginGoneon the now-current screen.applyAvailability()now reports whether it actually applied;confirmGone()ANDs that in.NavType.StringTypematching).Uri.encode()it; Nav decodes on receipt.Deferred (reported, not fixed — your call)
The UI-layer lens flagged several lower-severity items I left for you to decide on, since they're either UX-policy choices or need an architectural call:
isAuthExpired()is effectively dead on the Book Club path — an expired token leaves a permanent retryable error instead of routing to login. Needs a central Authenticator decision (app-wide), not a Book-Club-local patch.DateFormat.isPast(closesAt)compares the server's MySQL wall-clock asLocalDateTimeto device-localnow(); a TZ mismatch can show a ballot open (then 409) or hidden while open. Needs the server-TZ contract pinned down.PullToRefreshBox) — a user who joins a club on the web can't pull-to-refresh the empty state. Quick fix (wrap inverticalScroll) but wanted eyes-on before touching Compose layout.confirmGone(consistency), snackbar dedup on identical messages,openWebsilent failure, progress-dialog dismiss-before-save.