react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

[🐛] 🔥Show index creation link on the error when querying with inequality filters on multiple fields

Open thisisgit opened this issue 8 months ago • 0 comments

Issue

Since firebase SDK released in April 2024, it now supports inequality filters on multiple fields and it returns a link to create required indexes when such query is triggered. The type of the error is under firestore/failed-precondition and currently, it returns Operation was rejected because the system is not in a state required for the operation's execution. Ensure your query has been indexed via the Firebase console. message instead of returning the link.

As I checked the code, I can find that it is being handled in RNFBFirestoreCommon.m for iOS and UniversalFirebaseFirestoreException.java for Android. The problem of current error handling implementation is that it only returns the original error message if there's query requires an index string in the error message: https://github.com/invertase/react-native-firebase/blob/ca07cadd592487102b035a24b55f593f065ef4a5/packages/firestore/ios/RNFBFirestore/RNFBFirestoreCommon.m#L156-L165

While the new error message looks like this: error

I was able to reproduce above error by updating the code in RNFBFirestoreCommon.m to always set message = error.localizedDescription;

I don't know if it's not safe to always return the original message but at least it needs to be updated to also match string like query requires multiple indexes to return original error message.


Project Files

Managed expo

Javascript

Click To Expand

package.json:

"@react-native-firebase/analytics": "20.0.0",
"@react-native-firebase/app": "20.0.0",
"@react-native-firebase/app-check": "20.0.0",
"@react-native-firebase/auth": "20.0.0",
"@react-native-firebase/crashlytics": "20.0.0",
"@react-native-firebase/firestore": "20.0.0",
"@react-native-firebase/functions": "20.0.0",

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • [x] I'm not using Pods
  • [ ] I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// N/A

Android

Click To Expand

Have you converted to AndroidX?

  • [ ] my application is an AndroidX application?
  • [ ] I am using android/gradle.settings jetifier=true for Android compatibility?
  • [ ] I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->

Environment

Click To Expand

react-native info output:

 OUTPUT GOES HERE
  • Platform that you're experiencing the issue on:
    • [ ] iOS
    • [ ] Android
    • [x] iOS but have not tested behavior on Android
    • [ ] Android but have not tested behavior on iOS
    • [ ] Both
  • react-native-firebase version you're using that has this issue:
    • 20.0.0
  • Firebase module(s) you're using that has the issue:
    • Firestore
  • Are you using TypeScript?
    • Y & 5.3.3

thisisgit avatar Jun 19 '24 14:06 thisisgit