Repository navigation
test(backend): decouple STT and from-segments tests from deployment state - #22595
Conversation
Replace retired JIT-budget imports with current request-ID behavioral coverage. Refresh the audio-copy fixture's vector cleanup dependency without changing production code or test gates. Refs #22552. Failure-Class: none
Assert CLIENT_FINALIZE in processor fakes. Replace collection-time package mutation with real tool imports, current async invocation and valid caller context; retain all sanitization assertions. Refs #22552. Failure-Class: none
Keep denied-provider fallback coverage explicit and add current hosted streaming selection cases. Preserve prerecorded/PTT restrictions, retry behavior and all serving/deployment configuration. Refs #22552. Failure-Class: none
Run all six Joan privacy cases through their real URL instead of the unrelated renamed person handler. Keep fresh from-segments router/auth construction in fixture setup without changing CPU limits or request assertions. Refs #22552. Failure-Class: none
|
Verdict: the test repairs here are correct and well-scoped, and the remaining CI failure is not from this diff — one action item below. CI root cause (not this PR): all six "Backend unit shard" jobs fail in the pyright pass of the authoritative backend unit contract step, on reportUnnecessaryIsInstance errors in backend/database/desktop_previews.py — a file this PR does not touch. Your merge-base (1e1879f) predates the current rework of that file on main, and current main passes the same gate. Merging or rebasing main onto this branch should clear the failure. The pytest portion of every shard ran green (0 failed). File notes:
Security / blast radius: tests only — no production path, workflow, or dependency changed; no new external calls. USER IMPACT: none — internal test-only change; users will not notice anything different. What I'd still want: (1) merge/rebase current main so the stale desktop_previews.py pyright errors clear and the suite goes green on this head; (2) once CI is green, mark the PR ready for review. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…contracts # Conflicts: # backend/tests/unit/test_users_joan_followup_tombstone_guard.py
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Pushed 15b6af2: merged current main (8edd56d) and resolved the conflict by taking main's test.
Still differs from main:
|
kodjima33
left a comment
There was a problem hiding this comment.
Test-only PR (no production code change per body); the production fix it originally carried was already superseded by main's #22494. Not a 'fix' under the confidence gate (test(backend) title, no linked bug) -> approve only.
…sites Main's backend CI is green on its own, so the preview/sync and backend test repairs merged in for validation (#22558, #22595) are no longer needed here; those files now match main and remain in their own PRs. This branch's diff against main is the checkout-first protection only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…from upgrade's Merging main kept this branch's earlier reverts of #22558 and #22595's test files, which would have undone their now-merged coverage; those files now match main. The branch's diff is the checkout protection plus the client fix below. The new checkout 409 means an existing subscription, but Flutter, macOS, web and Windows mapped every 409 to "Resubscribe first", which is only the upgrade route's pending-cancellation refusal. Checkout errors now show the existing-subscription reason; the upgrade mapping is renamed so it cannot classify checkout responses again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
## Summary Refs #21869. Follow-up to #22193: protect users who go directly to checkout before subscription-read reconciliation has healed their stored paid plan. - Extend the existing shared checkout/reactivation boundary to verify the raw stored Stripe subscription ID even when the effective local plan is Free and the root customer ID is absent. - Keep same-plan/interval pending-cancellation reactivation. Other nonterminal subscriptions return HTTP 409; unverified Stripe state or failed reactivation returns retryable HTTP 503, never a second Checkout session. - Allow confirmed terminal subscriptions and definitive retrieve-only `resource_missing`/404; preserve new-buyer, referral and one-time PaymentIntent-grant behavior. - Keep storefront reads, plan-change/upgrade rails, customer identity and blocked-path entitlements unchanged. Log error types only, not Stripe response bodies. ## Root cause and durable prevention The validity projection can discard a stale paid record's Stripe ID when presenting it as Basic. Customer-based eligibility cannot recover it when the root customer ID is missing. The existing reactivation helper already retrieves the raw stored ID, but previously returned `None` for active subscriptions and swallowed provider/modify/persistence errors, allowing fresh checkout. The shared primitive is that existing boundary: `None` now means no existing recurring subscription was found or the stored one is confirmed ended/missing, not simply "reactivation did not happen." Regression tests execute the real HTTP route, real eligibility and actual Checkout builder with fake persistence and Stripe SDK objects, asserting no billing creation on blocked requests. No additional standalone checker or storefront mutation was introduced. Failure-Class: new New class: `FC-checkout-falls-through-unverified-subscription`. ## Verification - Regression reproduced before the fix: active/trialing/past_due subscriptions incorrectly returned HTTP 200 and reached new Checkout creation. - 266 targeted tests passed in isolated per-file pytest processes: 35 new checkout-first HTTP regressions plus 231 existing payment, eligibility, subscription healing/state/plan, terminal-status and webhook tests. - All 34 selected `make preflight` checks passed on commit `0e5f5f642c3ac64014b58b84ccf7e13a4bd80683`. The history-dependent failure-class recurrence audit explicitly skips on this shallow clone; CI with full history remains authoritative for that audit. Catalog consistency and async-blocker scan passed; PR metadata/failure-class validation passed. - The remaining bounded push checks passed, including the two changed test files (55 tests), runtime-source closure, released app-client OpenAPI compatibility/export, generated Dart/TypeScript/Swift model checks and pinned formatting. Only the documented local skips below were used. GitHub CI is not claimed green. - Local uvicorn/curl smoke passed with the real payment router, overridden auth, and mocked provider/persistence boundaries. No real Stripe or Firestore writes. Example request: ```bash curl -sS -X POST http://127.0.0.1:58550/v1/payments/checkout-session \ -H 'Content-Type: application/json' -d '{"price_id":"price_checkout_current"}' ``` | Fixture | HTTP | Fresh Checkout creates | Existing reactivations | | --- | --- | --- | --- | | Active subscription, missing root customer ID | 409 | 0 | 0 | | Stripe unavailable | 503 | 0 | 0 | | Confirmed ended subscription | 200 | 1 | 0 | | Same-plan pending cancellation | 200 | 0 | 1 | Local fixture-backed server stopped after smoke testing. The CI-selected 52-file run passed: **1,770 tests passed**, with 37 tests deselected by the normal `not integration and not slow` expression (two files entirely deselected). The 34 subscription-restructure tests also passed separately without that marker filter in the targeted run above. An initial local run hit the stricter default 0.30-second CPU guard on the unchanged generated-compute inventory test; the verification run uses CI's existing 1.0-second budget, without changing any repository setting. Reproduction commands (from `backend/`, with a repository-relative changed-path list): ```bash .venv/bin/python -m pytest tests/unit/test_checkout_first_subscription.py -q .venv/bin/python scripts/select_backend_unit_tests.py \ --changed-files /private/tmp/omi-21869-checkout-changed.txt \ --output /private/tmp/omi-21869-checkout-tests.txt BACKEND_UNIT_TEST_FILE_LIST=/private/tmp/omi-21869-checkout-tests.txt \ BACKEND_PYTEST_WORKERS=4 BACKEND_FAST_UNIT_FAIL_SECONDS=1.0 \ PYTHON=.venv/bin/python bash test.sh .venv/bin/python scripts/generate_plan_catalog.py --check --base-ref origin/main .venv/bin/python scripts/scan_async_blockers.py --dirs routers utils ``` ### Validation on current main (2026-10-20) This PR no longer bundles #22558 or #22595. They were merged in earlier only to get backend CI green; main's backend CI is green on its own now, so those files match main here and stay in their own PRs. The diff against main is the checkout-first protection alone: `routers/payment.py`, its two test files, `checkout-admission.md` and the failure-class record. - The 20-file billing selection (checkout-first, promotion codes, payment, Stripe ledger and subscription tests) passes under `test.sh`: 279 passed. - `routers/payment.py` passes the pinned type check (0 errors). - The four local fixture-backed curl admission outcomes described above are unchanged by this rebase; they were not re-run. ### Client handling of the new 409 Checkout's new 409 means the account already has a subscription. Flutter, macOS, web and Windows had mapped every 409 to "Resubscribe first to change plans.", which is only the upgrade route's pending-cancellation refusal. Checkout errors now show the existing-subscription reason ("You already have a subscription. Manage your existing subscription instead of starting a new checkout."); the upgrade route keeps "Resubscribe first". The upgrade-only helpers are renamed (`isUpgradePendingCancelConflict`, `SubscriptionPlanPresentation.upgradeErrorMessage`, web `purchaseErrorMessage(error, route)`, Windows `startCheckout` returning `existing_subscription`) so a checkout response can't be misclassified again. UI-Evidence: none Only which error sentence appears changes; no layout or control changes. Reproducing it live needs a real account with an existing subscription. Covered instead by Flutter (`plans_sheet_cancel_pending_test.dart`, `paywall_cancel_pending_test.dart`), macOS (`SubscriptionPlanPresentationTests`), web (`PlansSheet.cancelPending.test.tsx`, `cancelPending.test.ts`) and Windows (`billing.test.ts`, `PlanUsageTab.cancelPending.test.tsx`) tests. ## Architecture and release scope Architecture and implementation/release checklist: `backend/docs/checkout-admission.md`. Line-Count-Exception: backend/routers/payment.py | 1789 -> 1809 | Keep this 20-line safety expansion in the existing checkout/reactivation boundary; extracting unrelated payment routes would broaden this billing fix and its regression surface. This PR does not deploy, flip flags, repair customer data, cancel subscriptions, deduplicate historical purchases or serialize concurrent first-time checkout requests. Accounts missing both stored subscription ID and customer ID remain outside this bounded repair. Keep #21869 open pending separately authorized rollout and affected-account verification. GCP deployment verification is not claimed. Prior browser attempts could not list Cloud Run resources, and no usable ADC/read-only profile was found then. This code-only task performs no deployment or serving-revision verification. ## Product invariants affected none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/22552?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/22552?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F22552&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-off-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-off-auto-fix-light.svg"><img alt="Turn off auto-fix" src="https://www.cubic.dev/buttons/turn-off-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. --> ## 2026-10-23 maintainer review and merge gates Ready for code review at Aryan's request; pushed 5d2f03f. The checkout-vs-upgrade mapping and earlier stacked-test reversals have already been repaired on this head. Fixed the remaining Flutter conflict-message localization using the existing l10n tool across every current locale (49 at verification). Both purchase surfaces select the localized string from checkout HTTP 409; the upgrade pending-cancellation message is unchanged. Fourteen focused Dart tests pass, including English, German and Arabic on both surfaces; the two isolated backend checkout/promotion files pass 55 tests. Localization checks and all 60 selected preflight checks pass. The push used the documented PRE_PUSH_SKIP_DESKTOP_SWIFT=1 hatch for an unchanged native subtree under local memory pressure; git verified no macOS source changes since the preceding remote head. Exact-head CI remains authoritative for that compile. The prospective merge also preserves the five previously repaired regression files. No actual Stripe/Firestore writes or customer repair were performed. Stripe sandbox pass on 5d2f03f (2026-10-23, test mode only): the real checkout and customer-portal routes ran against a Stripe sandbox with real subscriptions, in-memory Firestore rows only. 10/10 scenarios behaved as specified: new buyer gets a session; an active subscription is refused with no session created (400 from the existing eligibility check when the customer ID is known, the new 409 when it was lost locally); pending cancellation on the same plan reactivates without checkout, including when the local row is missing; a different plan stays blocked; canceled and deleted subscription IDs get a fresh session; unverifiable Stripe state returns 503 with no session; the billing portal opens. Exact-head CI is green. Installed-client check (2026-10-23): the Flutter dev build of 5d2f03f on the iOS Simulator, signed in as the synthetic local-dev user against a local backend using the same Stripe sandbox, showed "You already have a subscription. Manage your current subscription instead of starting a new one." for a stale record whose Stripe subscription was incomplete (the read-heal only promotes active/trialing, so this is the state that reaches checkout from the app). No Checkout Session was created. Still required before merge: maintainer review. The first exact-head Linux helper packaging attempt failed while downloading Ubuntu runtime packages: the dependency-install step timed out at five minutes, before helper smoke execution. No application error was shown by that failure. Re-ran only that failed job once; the retry is not counted as a pass until it completes. No pipeline timeout, dependency pin or security gate was weakened.
Summary
Makes three backend test files independent of deployment state and the fast-unit CPU budget. Main's backend CI is green, and most of the drift this PR first repaired has since been fixed on main (#22494, #22539); those edits were dropped in favor of main. What remains:
test_developer_from_segments_idempotency.py: asegment_api_clientfixture builds the FastAPI router and auth overrides once, outside the request being measured, so router setup no longer counts against the fast-unit CPU guard.test_modulate_stt.py: the "Deepgram disabled" cases patchPROVIDER_SERVING_SURFACESexplicitly instead of relying on whichever providers the current policy happens to disable. They are renamed from "retired" to "disabled" to say what they test.test_streaming_deepgram_backoff.py: adds coverage that a configured cloud Deepgram serves the available streaming languages, alongside the existing refusal cases.Verification
Failure-Class: none
Product invariants affected
none
🤖 Generated with Claude Code