Skip to content

fix(book-club): review follow-ups — envelope null-data crash, atomic flag, stale-instance gone, slug encoding#18

Merged
fabiodalez-dev merged 1 commit into
mainfrom
fix/book-club-review-followups
Jul 6, 2026
Merged

fix(book-club): review follow-ups — envelope null-data crash, atomic flag, stale-instance gone, slug encoding#18
fabiodalez-dev merged 1 commit into
mainfrom
fix/book-club-review-followups

Conversation

@fabiodalez-dev

Copy link
Copy Markdown
Owner

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:compileDebugKotlin passes.

Fixes

  • BookClubResultbookClubCall() mapped a bodiless success ({success:true, data:null}) to Success(Unit as T) through an unchecked cast, so a data-bearing endpoint (clubs/clubDetail/dashboard/join) returning no data crashed the ViewModel with ClassCastException on res.data. Split into bookClubCall<T> (null data → Failure) and bookClubCallUnit for the Envelope<Unit> endpoints (health/propose/vote/rsvp/progress). The unchecked cast is gone.
  • FeatureStore.setBookClubAvailable() — non-atomic read-modify-write on the StateFlow could clobber a concurrent flag update from a parallel health refresh. Now _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 now-current screen. applyAvailability() now reports whether it actually applied; confirmGone() ANDs that in.
  • Routes.clubDetail() — the raw slug was interpolated into the nav route without URL-encoding (a slug with a slash/reserved char would break NavType.StringType matching). 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:

  • 401 → re-login: 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.
  • Poll deadline timezone: DateFormat.isPast(closesAt) compares the server's MySQL wall-clock as LocalDateTime to device-local now(); a TZ mismatch can show a ballot open (then 409) or hidden while open. Needs the server-TZ contract pinned down.
  • Pull-to-refresh dead on empty/error/gone states (non-scrollable Columns inside PullToRefreshBox) — a user who joins a club on the web can't pull-to-refresh the empty state. Quick fix (wrap in verticalScroll) but wanted eyes-on before touching Compose layout.
  • Minor UX: action-404 not funneled through confirmGone (consistency), snackbar dedup on identical messages, openWeb silent failure, progress-dialog dismiss-before-save.

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

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@fabiodalez-dev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c090dff9-d5c8-4a40-86f5-709fcdddb8fb

📥 Commits

Reviewing files that changed from the base of the PR and between fe0bc84 and 23bb768.

📒 Files selected for processing (4)
  • app/src/main/java/com/pinakes/app/data/network/BookClubResult.kt
  • app/src/main/java/com/pinakes/app/data/repository/BookClubRepository.kt
  • app/src/main/java/com/pinakes/app/data/store/FeatureStore.kt
  • app/src/main/java/com/pinakes/app/ui/navigation/Routes.kt
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/book-club-review-followups

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@fabiodalez-dev fabiodalez-dev merged commit 9ddc37f into main Jul 6, 2026
1 of 2 checks passed
@fabiodalez-dev fabiodalez-dev deleted the fix/book-club-review-followups branch July 6, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant