Repository navigation
Play Billing: final pre-switch-on fixes (follow-up to #26159) - #26163
Merged
Merged
Conversation
…, no trial length while the provider is unknown
…rker failure fields, re-read Google before purge - cancel_for_account_deletion keeps going when one purchase cannot be confirmed, cancels and stamps the rest, then raises the first PlayCancelPending. - A new grace intent and a restore reset grace_actions_failed_attempts, grace_actions_last_failed_at and grace_actions_overdue, so a second deletion counts from zero. - purge_account_records reads Google once per purchase right before deleting and refuses (wipe retries) when a purchase can charge or be restored again.
kodjima33
marked this pull request as ready for review
November 23, 2026 19:09
kodjima33
added a commit
that referenced
this pull request
Nov 23, 2026
…ook, failed-read state (follow-up to #26163) (#26165) ## 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 1. **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 at `play_billing_records` until 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. 2. **Operator instructions live in the repo.** New `backend/docs/runbooks/play-billing-deletion.md` (48 lines) covers: - **The two stuck states:** the grace-mode cancel keeps failing at admission, or the wipe fails on Play at its billing step or at `play_billing_records`. - **Why the old filter never matched:** the backend logs in text mode (`backend/main.py` `default_format='text'`), so `logger.critical` lands as severity ERROR. - **Cloud Logging filters built on `severity>=ERROR`:** the text is checked against the code's messages and against what `sanitize()` leaves (it masks the purchase key to `a1b***5f6`, and the filter text survives it). - **The PostHog failure events.** - **What an operator does** for a 403, a 5xx or a chargeable-again purchase, and for a purchase not confirmed in this run. A wipe failing at `play_billing_records` already went through the shared failure path (`wipe_status=failed`, ERROR log, `Account Deletion Wipe Failed`). But `failed_operations` listed 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. 3. **Dedicated failed-read state.** `UsageProvider` keeps `_subscriptionReadFailed`, which only a subscription read sets (null or exception) and clears (at its start and on success), and which a session reset clears. `billingProviderFailed` and `billingProviderPending` are based on it, not on the shared `_error` that usage, plans and checkout calls clear. `restorePurchases` still reads `_error` right 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. 4. **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". 5. **Nits.** - **Hosts:** `_hostOf` strips every trailing dot, and test rows cover `app.omi.me..`, `h.omi.me...` and `www.omi.me..`; these fail on the old one-dot strip. - **Skeleton height: not changed.** The real timeline card's height depends on its content: measured in a widget test it is 265 px at 430 wide and 535 px at 360 wide at normal text size, and up to 1747 px at 1.3x text. No constant skeleton matches it. Matching exactly would mean laying out the hidden card with its 7-day text still in the tree, which #26159 removed on purpose. The skeleton stays 120 px, and the page can shift when the read lands. ## Product invariants affected - INV-MEM-3: `backend/services/users/account_deletion.py` wipe 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 - Backend, one process per file: `test_play_billing_money` 65, `test_play_billing` 62, `tests/services/users/test_account_deletion` 115, `test_lake_wipe_step` 72, `test_account_deletion_single_executor` 9: all passed. - App (Flutter 3.44.5): `play_billing_plans_sheet_test` 29, `app_detail_paid_billing_test` 6, `omi_shop_hardware_test` 10, `omi_shop_web_page_test` 5, the trial, outline, router, plans sheet, onboarding and app install suites, and the four `usage_provider_*` test files: all passed. `flutter analyze` on the changed files: no issues. - `scripts/pr-preflight --pr-body-file` on this body and the push gate. - Not run: any device, emulator, live Google call or live Cloud Logging query (the runbook filters are checked against the code and the logging setup, not against the real log stream). ## 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 <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/26165?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/26165?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26165&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
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
Last pre-switch-on follow-up to #26159 (merged as b56435b; Play Billing still off for everyone). It covers the general review's three nits and the money review's must-fixes 1 to 5 from the #26159 reviews. No prod switch values change.
App (cherry-picked a3c129f23d, reviewed)
omi_shop.dartstrips one trailing root dot before every host comparison, sohttps://app.omi.me./andhttps://www.omi.me./products/omi-proget the same decisions as their normal forms (blocked from checkout and payment pages too). Tests cover both from each origin.Backend (money)
cancel_for_account_deletioncatchesPlayCancelPendingper purchase, keeps cancelling and stamping the rest, and raises the first error at the end. The unconfirmed purchase is not stamped, so the purge keeps refusing until a retry confirms it. Test: two purchases, the first read 503s, the second is ACTIVE: the second is cancelled and stamped, and the wipe still fails as pending.grace_actions_failed_attempts=0,grace_actions_last_failed_at=None,grace_actions_overdue=False. Tests: fail 5 times and go overdue, restore, delete again: the merged marker is back to zero with no overdue flag, and the next failed attempt is recorded as attempt 1.play_publisher.purge_account_recordsreads Google once per purchase immediately before the delete (one extra read per purchase per wipe run). If a purchase can charge or be restored again, it raisesPlayCancelPending(token hash only) and nothing is deleted; the retried wipe cancels it again. Test: cancel, resubscribe the same purchase, purge refuses and keeps the doc, the next run cancels again and the purge goes through.backend/charts/monitoring/alerts/*.json, mirrored intoalert-rules.json, fed by Prometheus counters or Cloud Monitoring log-based metrics, and guarded bybackend/tests/unit/test_monitoring_alert_rule_contract.py. Two failure classes rule out a quick rule.FC-alert-rule-scans-raw-log-linesbans rules that query raw log lines.FC-alert-never-provably-firedrequires a new rule's expression to be evaluated against real bad and good history before merge, and with Play off there is no bad period to evaluate. A proper rule (new counter, rule, metric-inventory entry, contract test, measured evaluation) is larger than this PR's budget and should follow once one Play deletion has run. Until then an operator should alert in Cloud Logging on the backend service with:severity=CRITICAL AND (textPayload:"delete_account grace immediate-action retry failed" OR jsonPayload.message:"delete_account grace immediate-action retry failed") AND (textPayload:"overdue=True" OR jsonPayload.message:"overdue=True")(the line also carries
attempts=andage_seconds=). The PostHogAccount Deletion Wipe Failedevent keeps no uid and no marker reference: none of its sibling deletion events carry one, so none is added.Product invariants affected
backend/database/account_deletion_grace.pymarker fields,utils/play_publisher.pycancel and purge used byservices/users/account_deletion.py). Deletion still never completes while Google can charge; memory and privacy deletion order are unchanged.How it was verified
test_play_billing_money61,test_play_billing62,tests/services/users/test_account_deletion114,test_claim_deletion_wipe_txn42,test_batch_account_authority_writers653,test_lake_wipe_step72,tests/routers/test_users330: all passed.omi_shop_hardware_test10,app_detail_paid_billing_test4,play_billing_plans_sheet_test27,omi_shop_web_page_test5,trial_paywall_page_test5,app_install_flow_test19: all passed.flutter analyzeon the changed files: only a pre-existing info attrial_paywall_page.dart:182.scripts/pr-preflight --pr-body-fileon this body and the push gate.UI evidence
UI-Evidence: none -- state changes on existing screens, no new screen. On Android: the paid Marketplace app button (loading while the billing provider is unknown; "Not available on Android" after a failed read; one retry when the page opens), and the trial paywall timeline (hidden: skeleton while the provider read is in flight, nothing after it failed). Hosts ending in a dot in the hardware-only store get the same block message as their normal form. Android device evidence comes from the pending emulator test; widget tests cover each state.
Failure class (fixes)
Failure-Class: none