Skip to content

fix(app): honor OMI_AUTH_CALLBACK_SCHEME build-time define for preview builds - #22052

Open
ocakciomursel-pixel wants to merge 3 commits into
BasedHardware:mainfrom
ocakciomursel-pixel:fix/auth-callback-scheme-define
Open

ocakciomursel-pixel wants to merge 3 commits into
BasedHardware:mainfrom
ocakciomursel-pixel:fix/auth-callback-scheme-define

Conversation

@ocakciomursel-pixel

@ocakciomursel-pixel ocakciomursel-pixel commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

Closes #19244.

  • Honor OMI_AUTH_CALLBACK_SCHEME build-time define (app/lib/env/env.dart): Production-profile preview builds signed with their own bundle ID share AppEnvironmentProfile.production.authCallbackScheme (omi) with the App Store Omi app. When both are installed on the same iOS device, iOS routes the omi://auth/callback OAuth redirect to the App Store app instead of the preview build. Env.authCallbackScheme now reads String.fromEnvironment('OMI_AUTH_CALLBACK_SCHEME') when non-empty and falls back to profile.authCallbackScheme, exposed via Env.authCallbackSchemeForProfile for unit testing.

Product invariants affected

none

How it was verified

Added unit test coverage in app/test/unit/env_test.dart exercising Env.authCallbackSchemeForProfile with and without a defined scheme override across production and mobileBeta profiles.

Tests

  • app/test/unit/env_test.dart

UI evidence

UI-Evidence: none -- build-time environment configuration and unit test only.

Failure class (fixes)

Failure-Class: none

View guided diff

@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: the production change is correct, minimal, and implements exactly the fix suggested in #19244; one wiring gap to address before merge.

  • app/lib/env/env.dart — _authCallbackSchemeFromDefine (String.fromEnvironment('OMI_AUTH_CALLBACK_SCHEME')) with fallback to configuredProfile.authCallbackScheme is the right shape: with the define unset, behavior is byte-identical for every released profile (environment_profile.dart still maps production/local_prod -> omi, mobileBeta -> omi-beta, localDev -> omi-dev), and authRedirectUri picks up the override automatically. The doc comment explaining the iOS redirect collision is accurate.
  • app/test/unit/env_test.dart — the new test covers the three cases that matter: no define -> profile value, define -> override, empty define -> fallback.

The gap: the dart-define only changes the redirect URI the app requests; the scheme iOS actually registers still comes from AUTH_CALLBACK_SCHEME in app/ios/Flutter/Base.xcconfig (default omi; omi-dev for the dev flavor) via $(AUTH_CALLBACK_SCHEME) in Runner/Info.plist's CFBundleURLSchemes, and app/setup.sh writes it into ios/Flutter/Custom.xcconfig. A production-profile preview build that sets only OMI_AUTH_CALLBACK_SCHEME=omi-preview will send omi-preview://auth/callback but still register omi://, so the returning browser opens nothing — a worse failure than today's wrong-app redirect. Please wire the two together (e.g. have setup.sh set both, or derive one from the other) or at minimum document the pairing wherever preview builds are described.

Security: low — the define is a build-time constant selecting among custom schemes; no new runtime input reaches the redirect URI. Blast radius: only builds that opt into the define; released builds unchanged.

USER IMPACT: none for App Store or beta builds — nothing changes unless a build explicitly sets OMI_AUTH_CALLBACK_SCHEME.

Still wanted as a reviewer: a note or assertion tying OMI_AUTH_CALLBACK_SCHEME to the native AUTH_CALLBACK_SCHEME so they cannot diverge, and optionally a trim on the define value (a whitespace-only define passes isNotEmpty and would produce a broken URI).

Auth redirect flow change — leaving for human maintainer review of the native-scheme pairing before merge.

Automated review on behalf of the Omi maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added flutter flutter work needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution labels Oct 17, 2026
…BACK_SCHEME in setup.sh

- Trim definedScheme in authCallbackSchemeForProfile so whitespace-only defines fall back to profile default
- Add unit test coverage for whitespace-only and padded defines in env_test.dart
- Wire OMI_AUTH_CALLBACK_SCHEME in setup.sh: set AUTH_CALLBACK_SCHEME in ios/Flutter/Custom.xcconfig and forward dart-define to flutter run
@ocakciomursel-pixel

Copy link
Copy Markdown
Contributor Author

Thanks @Git-on-my-level for the feedback and for catching the native scheme pairing!

Updated in commit 84bd890:

  1. Trim define value: authCallbackSchemeForProfile in app/lib/env/env.dart now trims definedScheme before testing .isNotEmpty, preventing whitespace-only defines from producing invalid URIs.
  2. Unit tests: Added test assertions in app/test/unit/env_test.dart covering whitespace-only define fallback and whitespace-padded define stripping.
  3. Native Scheme Pairing in setup.sh:
    • generate_ios_custom_config now reads ${OMI_AUTH_CALLBACK_SCHEME:-${2:-$default_scheme}} and writes AUTH_CALLBACK_SCHEME=${callback_scheme} into ios/Flutter/Custom.xcconfig (which feeds $(AUTH_CALLBACK_SCHEME) in Runner/Info.plist).
    • run_build_ios forwards --dart-define=OMI_AUTH_CALLBACK_SCHEME=${OMI_AUTH_CALLBACK_SCHEME} so Dart and iOS Info.plist stay automatically synchronized.
    • Documented the preview build pairing in app/setup.sh usage.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Dart-side override is correct and nicely tested, but the build wiring doesn't actually deliver it on iOS — the advertised workflow still fails, so this needs one more pass.

What's good:

  • app/lib/env/env.dart — authCallbackSchemeForProfile trims the define and falls back to configuredProfile.authCallbackScheme on empty/whitespace, so builds without OMI_AUTH_CALLBACK_SCHEME behave exactly as before. The doc comment explains the iOS redirect-collision root cause well.
  • app/test/unit/env_test.dart — solid coverage of the override, fallback (production → omi, mobileBeta → omi-beta), and whitespace-trim cases.
  • app/setup.sh generate_ios_custom_config — writing AUTH_CALLBACK_SCHEME into ios/Flutter/Custom.xcconfig correctly moves the native CFBundleURLSchemes entry ($(AUTH_CALLBACK_SCHEME) in Runner/Info*.plist).

Blocking:

  1. run_build_ios (app/setup.sh ~518–574) never passes --dart-define=OMI_AUTH_CALLBACK_SCHEME to flutter run — the injection loop was added only to run_build_android (~351–362). So OMI_AUTH_CALLBACK_SCHEME=omi-preview bash setup.sh ios (the usage line this PR adds) registers omi-preview natively while Dart still redirects to omi://auth/callback: iOS keeps handing the callback to the App Store app, i.e. the exact #19244 failure. Please mirror the has_callback_define loop in run_build_ios (or hoist both into a shared helper).
  2. Android: run_build_android injects the define, but the scheme is hardcoded per flavor (android/app/src/dev/AndroidManifest.xml → omi-dev, src/prod → omi-beta) with no manifest placeholder. With the env var set on Android, the app requests a redirect no intent-filter matches, breaking sign-in there. Either wire a manifest placeholder through the Gradle config or don't inject on Android and document the define as iOS-only.

Security: the override is opt-in and developer-facing; custom-scheme redirects are inherently interceptable on shared devices, but that's pre-existing and the backend already accepts arbitrary schemes. Blast radius: released/default builds are unchanged (define absent → identical behavior); only opt-in preview builds are affected.

USER IMPACT: none for released builds — this only changes optional developer/preview build configuration.

Still wanted as a reviewer: the iOS define injection, the Android story (placeholder or iOS-only scoping), and a CI run on this head (no checks have reported yet).

Leaving for human maintainer review — this alters the OAuth callback-redirect configuration surface, and the build-flow direction needs sign-off from someone owning mobile release tooling.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level removed the positive-signal Automation verified a genuine fix/quality contribution label Oct 19, 2026
@ocakciomursel-pixel

Copy link
Copy Markdown
Contributor Author

Thanks @Git-on-my-level for the thorough review and catching both build-wiring gaps!

Updated in commit 4f3ca5ad:

  1. iOS Define Injection:
    • In run_build_ios (app/setup.sh), added the --dart-define=OMI_AUTH_CALLBACK_SCHEME injection loop right alongside the provenance defines so that running OMI_AUTH_CALLBACK_SCHEME=omi-preview bash setup.sh ios properly passes the define to flutter run.
  2. Android Scoping:
    • Removed the define injection from run_build_android. Android intent-filters use flavor-specific static schemes (omi-dev / omi-beta) and do not accept dynamic scheme defines without manifest placeholders.
    • Documented OMI_AUTH_CALLBACK_SCHEME in setup.sh as iOS-only, paired specifically with iOS Custom.xcconfig to prevent URL scheme collisions with the App Store app.

@Git-on-my-level
Git-on-my-level dismissed their stale review October 21, 2026 14:32

Dismissed as stale: both blocking concerns from this review are resolved on head 4f3ca5a — run_build_ios now injects --dart-define=OMI_AUTH_CALLBACK_SCHEME (app/setup.sh ~546-557), and the Android injection was removed with the define documented as iOS-only (~352-354).

@Git-on-my-level

Copy link
Copy Markdown
Member

Since my last review: addressed (iOS now injects the define in run_build_ios; Android injection removed and documented iOS-only) · still open (none of the prior blockers) · newly introduced (nothing blocking).

Both blocking issues from my earlier review are fixed; this now delivers the advertised OMI_AUTH_CALLBACK_SCHEME=omi-preview bash setup.sh ios workflow end-to-end.

  • app/setup.sh run_build_ios (~546–557): the has_callback_define loop now appends --dart-define=OMI_AUTH_CALLBACK_SCHEME=... when the env var is set, and correctly skips it if the caller already passed an explicit define. Paired with AUTH_CALLBACK_SCHEME in ios/Flutter/Custom.xcconfig, the native scheme registration and the Dart redirect URI now move together.
  • app/setup.sh run_build_android (~352–354): the define injection is removed and replaced with a clear iOS-only scoping comment. Android keeps its static flavor schemes (omi-dev/omi-beta), which resolves the mismatched-redirect risk I flagged.
  • app/setup.sh generate_ios_custom_config (~111–117): the default scheme is now config-aware (Dev → omi-dev, Prod → omi). Both existing call sites still pass the scheme explicitly, so current flows (dev, beta) are unchanged; the new default only matters for a Prod call without an explicit scheme, which did not exist before.
  • app/lib/env/env.dart: unchanged since my last review — the override trims the define and falls back to the profile scheme, so builds without the define behave exactly as before.
  • app/test/unit/env_test.dart: unchanged and still covers override, fallback, and whitespace-trim cases.

Security: the define is opt-in developer/preview build configuration; released and default builds are unchanged in behavior. Custom-scheme redirect interceptability on shared devices is pre-existing and untouched here.

USER IMPACT: none for released builds — this only improves optional developer/preview iOS builds, which can now complete sign-in next to the App Store app.

Still wanted as a reviewer: a CI run on this head (no checks have reported), and maintainer sign-off on this auth-adjacent build wiring before merge — leaving for human maintainer review.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@ocakciomursel-pixel

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level need human response

Thanks for confirming that both prior build-wiring blockers are fixed. Current head 4f3ca5a remains unchanged. Mobile App Checks and Repo Checks are awaiting maintainer workflow approval. Please approve the current-head runs and provide the mobile release/auth-tooling decision on the opt-in iOS callback-scheme override. The Android injection remains removed; real-device OAuth coexistence has not been independently demonstrated here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work needs-maintainer-review Needs a human maintainer to sign off before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Production-profile builds with their own bundle id can't finish sign-in when the App Store Omi is installed

2 participants