Skip to content

fix(app): keep staging routing to opted-in iOS TestFlight builds - #10214

Merged
mdmohsin7 merged 9 commits into
mainfrom
fix/android-beta-staging-routing
Jul 21, 2026
Merged

mdmohsin7 merged 9 commits into
mainfrom
fix/android-beta-staging-routing

Conversation

@mdmohsin7

@mdmohsin7 mdmohsin7 commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

Problem

Android beta builds were reaching the staging backend. Staging is meant to be an
iOS TestFlight-only, opt-in capability.

Change

Restores staging selection as an iOS TestFlight-only, opt-in path, and keeps
every other production-family build on production.

  • Env.stagingApiUrl / isStagingConfigured / isUsingStagingApi, backed by a
    STAGING_API_URL envied field on both prod and dev env classes.
  • testFlightApiEnvironment preference, defaulting to production — a
    TestFlight install only reaches staging after an explicit opt-in.
  • main.dart selects staging solely inside the isTestFlight branch, and only
    when that preference is set. Restores the orange STAGING banner.
  • Developer settings regains the Production | Staging toggle, gated on
    Env.isTestFlight && Env.isStagingConfigured.
  • codemagic.yaml bakes STAGING_API_URL into the iOS workflows only.

Why Android cannot reach staging

Three independent layers, any one of which is sufficient:

  1. EnvironmentDetector.isTestFlight() returns false unless Platform.isIOS,
    so the override never runs on Android.
  2. Android workflows bake no STAGING_API_URL, so there is no staging backend to
    select even if the runtime gate were bypassed.
  3. Env.validateStartupRouting still hard-pins every production-family build's
    baked config to https://api.omi.me/ before networking starts.

Selection is driven only by runtime TestFlight detection plus a user opt-in — no
build-identity/compile-time flag can place a build in staging, and a regression
test asserts that.

Tests

  • test/unit/env_test.dart: new staging routing stays TestFlight-only group —
    the override stays nested under isTestFlight behind the opt-in, and no
    build-identity flag can select staging. 11/11 pass.
  • test/providers/capture_provider_test.dart + env_test.dart: 77/77 pass.
  • bash scripts/analyze_ratchet.sh: passed (prefer_const_constructors improved,
    451 vs baseline 465).
  • dart format --line-length 120: clean.

Note

Shipping this to users requires a fresh Android internal-track build; the live
build predates the fix.

Failure-Class: none

Review in cubic

Adds Env.stagingApiUrl, isStagingConfigured and isUsingStagingApi backed by the
STAGING_API_URL environment field. These only describe the configured staging
backend; validateStartupRouting still pins every production-family build.
Defaults to production, so a TestFlight install reaches staging only after the
user explicitly opts in.
Staging is selected at startup solely inside the TestFlight branch and only when
the user opted in. isTestFlight() is false off iOS, so Android and store builds
keep the production backend. Restores the staging banner for opted-in builds.
Gated on Env.isTestFlight && Env.isStagingConfigured, so it is reachable only
from an iOS TestFlight build with a staging backend configured.
Pins the override inside the TestFlight branch behind the opt-in preference and
asserts no build-identity flag can select staging.
Android workflows carry no staging URL, so an Android build has no staging
backend to select even if the runtime gate were bypassed.
@mdmohsin7
mdmohsin7 merged commit 68b0ff9 into main Jul 21, 2026
28 of 32 checks passed
@mdmohsin7
mdmohsin7 deleted the fix/android-beta-staging-routing branch July 21, 2026 18:14
Git-on-my-level added a commit that referenced this pull request Jul 21, 2026
## Summary

Locks production-family customer data-plane continuity across mobile and
macOS.

- Removes the newly reintroduced TestFlight staging override: TestFlight
is a distribution channel, not a separate customer/account universe.
- Adds locked `INV-DATA-1`, requiring stable, internal, beta,
TestFlight, Play Internal, and Omi Beta to use canonical production
customer services.
- Extends the deterministic routing guard to pin all production
Codemagic mobile workflows plus the macOS Python and desktop APIs,
reject legacy beta/staging routing selectors, and assert the macOS Beta
identity + shipped Firestore project.
- Makes macOS production-family endpoint resolution ignore
process/bundled endpoint contamination. Development and explicitly
signed external-preview identities retain their distinct controlled
seam.

## Incident evidence

The prior Android regression was introduced by `52c1920d64` via
`OMI_BETA_RELEASE_RING`, then removed after it reached main. During this
work, `origin/main` reintroduced an iOS TestFlight-only
`STAGING_API_URL` option in #10214. That option still violates the same
customer-data continuity boundary, so this PR removes it and prevents
reintroduction.

## Product invariants affected

- INV-AUTH-1 — this PR changes `codemagic.yaml`, which is also an
existing protected auth-artifact surface; it does not change session
invalidation behavior.
- INV-DATA-1 — production-family customer data plane remains canonical
production across every release cohort.

## Verification

Passed:

```text
python3 .github/scripts/test_check_mobile_production_routing.py
# 7 tests passed

python3 .github/scripts/check-mobile-production-routing.py

cd app && flutter test test/unit/env_test.dart test/providers/capture_provider_test.dart
# 74 tests passed
```

Attempted targeted macOS Swift package tests
(`APIClientRoutingTests|ExternalPreviewBuildTests`). Dependency
compilation exhausted the host volume (120 MiB free) before compiling
this PR's Swift sources; the generated `.build` directory was removed,
restoring 3.9 GiB. A later local pre-push attempt also could not
complete the macOS dependency lane because SwiftPM's remote fetch did
not expose the lockfile-pinned FluidAudio commit, even though it was
present in the local cache. The focused source-level mutation tests and
Flutter regression tests above passed. CI should run the targeted Swift
suite on a provisioned runner.

## Failure class

Failure-Class: new
undivisible pushed a commit to undivisible/omi that referenced this pull request Sep 29, 2026
## Summary

Locks production-family customer data-plane continuity across mobile and
macOS.

- Removes the newly reintroduced TestFlight staging override: TestFlight
is a distribution channel, not a separate customer/account universe.
- Adds locked `INV-DATA-1`, requiring stable, internal, beta,
TestFlight, Play Internal, and Omi Beta to use canonical production
customer services.
- Extends the deterministic routing guard to pin all production
Codemagic mobile workflows plus the macOS Python and desktop APIs,
reject legacy beta/staging routing selectors, and assert the macOS Beta
identity + shipped Firestore project.
- Makes macOS production-family endpoint resolution ignore
process/bundled endpoint contamination. Development and explicitly
signed external-preview identities retain their distinct controlled
seam.

## Incident evidence

The prior Android regression was introduced by `e5e971fa37` via
`OMI_BETA_RELEASE_RING`, then removed after it reached main. During this
work, `origin/main` reintroduced an iOS TestFlight-only
`STAGING_API_URL` option in BasedHardware#10214. That option still violates the same
customer-data continuity boundary, so this PR removes it and prevents
reintroduction.

## Product invariants affected

- INV-AUTH-1 — this PR changes `codemagic.yaml`, which is also an
existing protected auth-artifact surface; it does not change session
invalidation behavior.
- INV-DATA-1 — production-family customer data plane remains canonical
production across every release cohort.

## Verification

Passed:

```text
python3 .github/scripts/test_check_mobile_production_routing.py
# 7 tests passed

python3 .github/scripts/check-mobile-production-routing.py

cd app && flutter test test/unit/env_test.dart test/providers/capture_provider_test.dart
# 74 tests passed
```

Attempted targeted macOS Swift package tests
(`APIClientRoutingTests|ExternalPreviewBuildTests`). Dependency
compilation exhausted the host volume (120 MiB free) before compiling
this PR's Swift sources; the generated `.build` directory was removed,
restoring 3.9 GiB. A later local pre-push attempt also could not
complete the macOS dependency lane because SwiftPM's remote fetch did
not expose the lockfile-pinned FluidAudio commit, even though it was
present in the local cache. The focused source-level mutation tests and
Flutter regression tests above passed. CI should run the targeted Swift
suite on a provisioned runner.

## Failure class

Failure-Class: new
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