Repository navigation
Play Billing: purge waits only on chargeable purchases, deletion runbook, failed-read state (follow-up to #26163) - #26165
Merged
Merged
Conversation
…ok, dedicated subscription-read failure state - The pre-purge Google read refuses only a chargeable purchase (ACTIVE, IN_GRACE_PERIOD, ON_HOLD, PAUSED, PENDING). A user-cancelled purchase with paid time left no longer holds erasure until the paid time ends. - Wipe failure telemetry always names the failing step, including play_billing_records after best-effort derived purge failures. - backend/docs/runbooks/play-billing-deletion.md: both stuck states, Cloud Logging filters that match the text-mode lines (severity>=ERROR), operator steps. - UsageProvider tracks a failed subscription read in its own flag, so usage and plans reads no longer turn the failed state back into pending. - Tests for the paid app page's retry on open; hosts drop every trailing dot.
kodjima33
marked this pull request as ready for review
November 23, 2026 19:28
kodjima33
added a commit
that referenced
this pull request
Nov 24, 2026
…nds the purchase, runbook cancel step (#26189) ## What changed and why Five small items the reviewers of #26165 and #26181 left open. None changes a price, a purchase path or an entitlement rule. 1. **Plans sheet keeps Retry after a failed plan read** (`play_plans_content.dart`, `PlayPlansLoading`). The loading state decided "failed" from the provider's shared error. A successful usage read clears that error, so the sheet went back to a skeleton with no Retry while the plan read was still known to have failed. It now uses `billingProviderFailed`, the same flag the paywalls and the paid app button use since #26165. 2. **A token store error ends the purchase as failed** (`play_billing.dart`, `_deliver`). If reading or writing the pending-token store threw, the purchase was never finished: the paywall waited forever and `PlayBilling.busy` stayed true, which since #26181 also switches the resume read off for the session. `_deliver` now catches, logs and returns a failed result. The cleanup write after the server has answered has its own catch, so a plan the server granted is still reported as bought; the token is then sent once more on the next launch. 3. **Trial paywall's "was something bought before the reader left" check reads fresh** (`trial_paywall_page.dart`). It could join a resume read that started before the purchase and offer the monthly trial to someone who had just paid. The 4 s timeout still bounds it. 4. **Runbook** (`backend/docs/runbooks/play-billing-deletion.md`): the step for a purchase stuck more than a day told the operator to find the order in Play Console by the user's order. By then the account's email is deleted and the purchase document holds no order id. It now points at the stored `purchase_token` and the cancel call the wipe makes. 5. **Test that Home mounts `PlanRefreshOnResume`**, so removing the wrapper fails a test. ## Product invariants affected none ## How it was verified - New tests, each checked to fail without its fix: - `play_billing_plans_sheet_test.dart`: the plans sheet loading state shows the error state, a usage read clears the shared error, and the error state with Retry is still there (shimmer before the fix). - `play_billing_test.dart`: a purchase with a token store that throws returns `failed` and `busy` is false (hung before the fix). A store that fails only on the cleanup write still returns `purchased`. - `plan_refresh_on_resume_test.dart`: Home's source mounts `PlanRefreshOnResume`. - `flutter test test/unit/play_billing_test.dart test/widgets/play_billing_plans_sheet_test.dart test/widgets/plan_refresh_on_resume_test.dart`: 70 passed. `flutter analyze` on the changed files: no new issues. ## UI evidence UI-Evidence: none -- no layout or copy change; the existing "Unable to load plans" state with Retry now stays on screen in a case where it used to fall back to the existing skeleton ## Failure class No `fix:` commits; no declaration required.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
Follow-up to #26163 (merged as a93d3a5; Play Billing still off for everyone). It fixes must-fixes 1 to 4 and the nits from that PR's review. No prod switch values change.
Changes
Purge no longer waits out paid time. The pre-purge Google read now refuses only a purchase that can charge, using the existing
_CHARGEABLE_STATES(ACTIVE, IN_GRACE_PERIOD, ON_HOLD, PAUSED, PENDING). A user-cancelled purchase with paid time left still gets the best-effort developer cancel in the cancel step. The purge then proceeds whatever Google answered, with a warning naming the masked purchase key, so erasure no longer stalls atplay_billing_recordsuntil the paid time ends. Tests: CANCELED with 20 days left and the developer cancel rejected (400): the purge goes through. ACTIVE or IN_GRACE_PERIOD at purge: still refused. Read error (503) at purge: still refused.Operator instructions live in the repo. New
backend/docs/runbooks/play-billing-deletion.md(48 lines) covers:play_billing_records.backend/main.pydefault_format='text'), sologger.criticallands as severity ERROR.severity>=ERROR: the text is checked against the code's messages and against whatsanitize()leaves (it masks the purchase key toa1b***5f6, and the filter text survives it).A wipe failing at
play_billing_recordsalready went through the shared failure path (wipe_status=failed, ERROR log,Account Deletion Wipe Failed). Butfailed_operationslisted only the derived purge's best-effort failures whenever there were any, hiding the step that actually failed. It now always includes the failing step. Test: a best-effort failure, then a refusal at the Play-records step →failed_operations == ['speech_profile_audio', 'play_billing_records'], no uid in the event.Dedicated failed-read state.
UsageProviderkeeps_subscriptionReadFailed, which only a subscription read sets (null or exception) and clears (at its start and on success), and which a session reset clears.billingProviderFailedandbillingProviderPendingare based on it, not on the shared_errorthat usage, plans and checkout calls clear.restorePurchasesstill reads_errorright after its own subscription read, unchanged. Tests: a failed subscription read followed by a successful usage read (which clears_error) stays failed. Retry shows on the outline and trial paywalls, with no timeline skeleton, and "Not available" on the paid app button. A successful subscription read clears the state.Retry-on-open test (a3c129f23d). The paid app page is opened after a failed read and a usage read that cleared the shared error. Exactly one more read runs, and five forced rebuilds start no more. A Stripe reader ends on Subscribe, and a second failure ends on "Not available".
Nits.
_hostOfstrips every trailing dot, and test rows coverapp.omi.me..,h.omi.me...andwww.omi.me..; these fail on the old one-dot strip.Product invariants affected
backend/services/users/account_deletion.pywipe failure telemetry now names the failing step, and the Play purge (utils/play_publisher.py) no longer holds erasure on a purchase that cannot charge. Deletion still never completes while Google can charge; memory and privacy deletion order are unchanged.How it was verified
test_play_billing_money65,test_play_billing62,tests/services/users/test_account_deletion115,test_lake_wipe_step72,test_account_deletion_single_executor9: all passed.play_billing_plans_sheet_test29,app_detail_paid_billing_test6,omi_shop_hardware_test10,omi_shop_web_page_test5, the trial, outline, router, plans sheet, onboarding and app install suites, and the fourusage_provider_*test files: all passed.flutter analyzeon the changed files: no issues.scripts/pr-preflight --pr-body-fileon this body and the push gate.UI evidence
UI-Evidence: none -- state changes on existing Android screens, no new screen: after a failed subscription read the outline and trial paywalls keep showing Retry and the paid Marketplace app button keeps showing "Not available on Android" even after other reads succeed; opening the paid app page retries the read once. Android device evidence comes from the pending emulator test; widget tests cover each state.
Failure class (fixes)
Failure-Class: none