Skip to content

feat(firebase): FirebaseDisabledError for dynamicLinks helpers - #306

Merged
TuCopFi merged 2 commits into
Developmentfrom
feat/firebase-disabled-error-guard
Aug 1, 2026
Merged

feat(firebase): FirebaseDisabledError for dynamicLinks helpers#306
TuCopFi merged 2 commits into
Developmentfrom
feat/firebase-disabled-error-guard

Conversation

@TuCopFi

@TuCopFi TuCopFi commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

Small harm-reduction fix. The two Firebase Dynamic Links helpers now throw a dedicated FirebaseDisabledError instead of a raw Firebase native error when FIREBASE_ENABLED=false (current state per .env.mainnet:9). Callers can catch specifically and degrade gracefully.

This is NOT the fix for Sentry TUCOPWALLET-8 (Firebase not initialized). That crash fires from ReactNativeFirebaseDynamicLinksModule.onNewIntent on the Android native side, before any JS runs. That one requires a product-level decision (activate Firebase / remove Firebase modules / stub google-services.json). Options captured in PENDING.md as a separate entry.

Changes

src/firebase/dynamicLinks.ts (+15 lines):

  • New FirebaseDisabledError class (exported).
  • createInviteLink and createJumpstartLink guard on FIREBASE_ENABLED before calling dynamicLinks().

Why this specifically

  • createInviteLink was already gated at the call site (src/invite/hooks.tsx:22 checks FIREBASE_ENABLED). Adding a helper-side guard is defensive redundancy.
  • createJumpstartLink was not gated (src/jumpstart/JumpstartEnterAmount.tsx:77 calls it directly). Before this PR, tapping "Enviar por link" in the jumpstart flow with Firebase disabled would throw an opaque Firebase native error the caller has no way to recognize. Now it throws FirebaseDisabledError which the caller can identify by err.name === 'FirebaseDisabledError' or instanceof.

Test plan

  • yarn build:ts (0 errors)
  • Follow-up: caller in JumpstartEnterAmount.tsx should catch FirebaseDisabledError and either disable the "Enviar por link" affordance or surface "Feature no disponible" toast. Not in scope for this PR (needs product input on the UX copy).

TuCopFi added 2 commits July 31, 2026 23:43
The two Firebase Dynamic Links helpers (createInviteLink and
createJumpstartLink) previously called dynamicLinks() unconditionally.
With FIREBASE_ENABLED=false (the current state per .env.mainnet), those
calls throw a Firebase native error that is hard for callers to
distinguish from other Firebase issues.

Now both helpers early-return with a dedicated FirebaseDisabledError so
callers can catch specifically and either:
- fall back to a plain web URL,
- disable the 'share via link' affordance,
- surface a friendly 'feature unavailable' message.

createInviteLink was already gated at its call site
(src/invite/hooks.tsx:22 checks FIREBASE_ENABLED before calling).
createJumpstartLink was NOT (src/jumpstart/JumpstartEnterAmount.tsx:77
called it directly); this change makes both safe from the helper's side.

Does not touch Sentry TUCOPWALLET-8 native-level crash (that fires from
ReactNativeFirebaseDynamicLinksModule.onNewIntent in the Android
auto-linked native module, before any JS runs). Separate product
decision tracked in PENDING.md (options A/B/C).
… test + add disabled-path test

The existing jumpstart-link test broke on PR #306 because it did not
mock FIREBASE_ENABLED, and the actual config value is false, so the new
guard in createJumpstartLink threw FirebaseDisabledError before reaching
the mocked buildLink.

Fixes:
- beforeEach sets FIREBASE_ENABLED=true and clears mocks so the happy-
  path test can hit buildLink as before.
- New test covers the disabled path: FIREBASE_ENABLED=false throws
  FirebaseDisabledError AND buildLink is never called (private key
  never reaches the native module, matching the existing security
  comment in createJumpstartLink).
@TuCopFi
TuCopFi merged commit e6de951 into Development Aug 1, 2026
10 checks passed
@TuCopFi
TuCopFi deleted the feat/firebase-disabled-error-guard branch August 1, 2026 05:07
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