react-native: Intent links opened from GMAIL cause java.lang.IllegalArgumentException

Description

Intents from links (we are using Branch.io for deeplinking), and while links from the browser or Messages, etc (and anything on iOS) work fine, links from android GMAIL cause a crash. App crashes in react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/Arguments.java in the fromBundle method. Adding some logs, it looks like in the case of GMail, the intent in including a value that is of Uri type (these are the key and value values from fromBundle):

System.out com.sippd.dev I key: org.chromium.chrome.browser.eenp value type: class java.util.ArrayList val: [] System.out com.sippd.dev I key: android.intent.extra.REFERRER value type: class android.net.Uri$StringUri val: android-app://com.google.android.gm/

Because this intent value is not a String or Boolean or Array/List, it is throwing java.lang.IllegalArgumentException: Could not convert class android.net.Uri$StringUri : android-app://com.google.android.gm/

React Native Version

0.71.6

Output of npx react-native info

System: OS: macOS 13.3.1 CPU: (12) arm64 Apple M2 Max Memory: 3.03 GB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 14.21.3 - ~/.nvm/versions/node/v14.21.3/bin/node Yarn: 1.22.18 - ~/.nvm/versions/node/v14.21.3/bin/yarn npm: 6.14.18 - ~/.nvm/versions/node/v14.21.3/bin/npm Watchman: 2023.04.10.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.12.0 - /Users/adammarr/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 Android SDK: Not Found IDEs: Android Studio: 2022.1 AI-221.6008.13.2211.9619390 Xcode: 14.3/14E222b - /usr/bin/xcodebuild Languages: Java: 11.0.18 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.6 => 0.71.6 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

I’m not fully sure on the technical aspects of branch and what might be different from branch vs another type of app link from GMail, but in this case it happens simply by opening the link in GMail that then turns into the app link Intent that causes RN to crash.

Snack, code example, screenshot, or link to a repository

Happens prior to any application code running.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

@cortinico @Pranav-yadav TBH, we thought this was a Branch.io issue at first, so spent some time back and forth with their support team until I was able to spend some time digging into the logs and src and found the real issue.

I can push a PR, np, what are your thoughts on solution? I was thinking just change the exception throw to a WARN log… “The bundle attribute ${attr name} is not a supported type [String, Boolean, List, Array] and will not be mapped”

How about we open a new issue (or convert this) to fix this w/ “Help Wanted” label so “anyone” interested can send a PR for the same? WDYT Nicola?

Yup we can open a follow-up here

you guys are crashing people’s applications when they aren’t passing specific types to an untyped Object in Bundle. This should be a warning, not something that crashes people’s application, its been quite a headache the last month to figure this error out.

Definitely, this is not a good DX. And, it needs to be fixed at some point in time.

Sidenote/Tip:

I always follow 2hr rule while debugging, If I can’t figure it out on my own within 2hr I just ask for help without wasting much time 😃

Yup this change is totally doable, are you up for sendign a PR to add a fallback for non supported types?

How about we open a new issue (or convert this) to fix this w/ “Help Wanted” label so “anyone” interested can send a PR for the same? WDYT Nicola?