Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cloud_firestore] [ios] incorrect number of path segments crashes app instead of showing a PlatformException #204

Closed
cbenhagen opened this issue Sep 23, 2019 · 1 comment

Comments

@cbenhagen
Copy link
Contributor

The following code has an invalid number of path segments.

final doc = await Firestore.instance.document('users').get();

On Android this will throw a PlatformException with a useful error message:

E/flutter ( 5148): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Invalid document reference. Document references must have an even number of segments, but users has 1, null)
E/flutter ( 5148): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter ( 5148): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
E/flutter ( 5148): <asynchronous suspension>
E/flutter ( 5148): #2      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:344:48)
E/flutter ( 5148): <asynchronous suspension>
E/flutter ( 5148): #3      DocumentReference.get (package:cloud_firestore/src/document_reference.dart:84:33)

On iOS the whole app crashes:

*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff23b98bde __exceptionPreprocess + 350
        1   libobjc.A.dylib                     0x00007fff503b5b20 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff23b98958 +[NSException raise:format:arguments:] + 88
        3   Foundation                          0x00007fff255eb7be -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
        4   Runner                              0x0000000105dfdf5c _ZN8firebase9firestore4util8internal4FailEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 268
        5   Runner                              0x0000000105b9fda2 _ZN8firebase9firestore3api17DocumentReferenceC2ENS0_5model12ResourcePathENSt3__110shared_ptr<…>

Looking at the following code I would expect a similar exception on iOS:
https://github.com/firebase/firebase-ios-sdk/blob/3e939a7ee29f8684b22ca57afd83533fed89e499/Firestore/Source/API/FIRDocumentReference.mm#L78-L85

Should we maybe catch these kind of user errors in dart before we even ask the platform specific code?

Podfile.lock:

PODS:
  - BoringSSL-GRPC (0.0.3):
    - BoringSSL-GRPC/Implementation (= 0.0.3)
    - BoringSSL-GRPC/Interface (= 0.0.3)
  - BoringSSL-GRPC/Implementation (0.0.3):
    - BoringSSL-GRPC/Interface (= 0.0.3)
  - BoringSSL-GRPC/Interface (0.0.3)
  - cloud_firestore (0.0.1):
    - Firebase/Core
    - Firebase/Firestore (~> 6.0)
    - Flutter
  - Firebase/Auth (6.9.0):
    - Firebase/CoreOnly
    - FirebaseAuth (~> 6.2.3)
  - Firebase/Core (6.9.0):
    - Firebase/CoreOnly
    - FirebaseAnalytics (= 6.1.2)
  - Firebase/CoreOnly (6.9.0):
    - FirebaseCore (= 6.3.0)
  - Firebase/Firestore (6.9.0):
    - Firebase/CoreOnly
    - FirebaseFirestore (~> 1.5.1)
  - firebase_auth (0.0.1):
    - Firebase/Auth (~> 6.0)
    - Firebase/Core
    - Flutter
  - firebase_core (0.0.1):
    - Firebase/Core
    - Flutter
  - FirebaseAnalytics (6.1.2):
    - FirebaseCore (~> 6.3)
    - FirebaseInstanceID (~> 4.2)
    - GoogleAppMeasurement (= 6.1.2)
    - GoogleUtilities/AppDelegateSwizzler (~> 6.0)
    - GoogleUtilities/MethodSwizzler (~> 6.0)
    - GoogleUtilities/Network (~> 6.0)
    - "GoogleUtilities/NSData+zlib (~> 6.0)"
    - nanopb (~> 0.3)
  - FirebaseAuth (6.2.3):
    - FirebaseAuthInterop (~> 1.0)
    - FirebaseCore (~> 6.2)
    - GoogleUtilities/AppDelegateSwizzler (~> 6.2)
    - GoogleUtilities/Environment (~> 6.2)
    - GTMSessionFetcher/Core (~> 1.1)
  - FirebaseAuthInterop (1.0.0)
  - FirebaseCore (6.3.0):
    - FirebaseCoreDiagnostics (~> 1.0)
    - FirebaseCoreDiagnosticsInterop (~> 1.0)
    - GoogleUtilities/Environment (~> 6.2)
    - GoogleUtilities/Logger (~> 6.2)
  - FirebaseCoreDiagnostics (1.1.0):
    - FirebaseCoreDiagnosticsInterop (~> 1.0)
    - GoogleDataTransportCCTSupport (~> 1.0)
    - GoogleUtilities/Environment (~> 6.2)
    - GoogleUtilities/Logger (~> 6.2)
  - FirebaseCoreDiagnosticsInterop (1.0.0)
  - FirebaseFirestore (1.5.1):
    - FirebaseAuthInterop (~> 1.0)
    - FirebaseCore (~> 6.2)
    - FirebaseFirestore/abseil-cpp (= 1.5.1)
    - "gRPC-C++ (= 0.0.9)"
    - leveldb-library (~> 1.22)
    - nanopb (~> 0.3.901)
    - Protobuf (~> 3.1)
  - FirebaseFirestore/abseil-cpp (1.5.1):
    - FirebaseAuthInterop (~> 1.0)
    - FirebaseCore (~> 6.2)
    - "gRPC-C++ (= 0.0.9)"
    - leveldb-library (~> 1.22)
    - nanopb (~> 0.3.901)
    - Protobuf (~> 3.1)
  - FirebaseInstanceID (4.2.5):
    - FirebaseCore (~> 6.0)
    - GoogleUtilities/Environment (~> 6.0)
    - GoogleUtilities/UserDefaults (~> 6.0)
  - Flutter (1.0.0)
  - GoogleAppMeasurement (6.1.2):
    - GoogleUtilities/AppDelegateSwizzler (~> 6.0)
    - GoogleUtilities/MethodSwizzler (~> 6.0)
    - GoogleUtilities/Network (~> 6.0)
    - "GoogleUtilities/NSData+zlib (~> 6.0)"
    - nanopb (~> 0.3)
  - GoogleDataTransport (2.0.0)
  - GoogleDataTransportCCTSupport (1.1.0):
    - GoogleDataTransport (~> 2.0)
    - nanopb
  - GoogleUtilities/AppDelegateSwizzler (6.3.0):
    - GoogleUtilities/Environment
    - GoogleUtilities/Logger
    - GoogleUtilities/Network
  - GoogleUtilities/Environment (6.3.0)
  - GoogleUtilities/Logger (6.3.0):
    - GoogleUtilities/Environment
  - GoogleUtilities/MethodSwizzler (6.3.0):
    - GoogleUtilities/Logger
  - GoogleUtilities/Network (6.3.0):
    - GoogleUtilities/Logger
    - "GoogleUtilities/NSData+zlib"
    - GoogleUtilities/Reachability
  - "GoogleUtilities/NSData+zlib (6.3.0)"
  - GoogleUtilities/Reachability (6.3.0):
    - GoogleUtilities/Logger
  - GoogleUtilities/UserDefaults (6.3.0):
    - GoogleUtilities/Logger
  - "gRPC-C++ (0.0.9)":
    - "gRPC-C++/Implementation (= 0.0.9)"
    - "gRPC-C++/Interface (= 0.0.9)"
  - "gRPC-C++/Implementation (0.0.9)":
    - "gRPC-C++/Interface (= 0.0.9)"
    - gRPC-Core (= 1.21.0)
    - nanopb (~> 0.3)
  - "gRPC-C++/Interface (0.0.9)"
  - gRPC-Core (1.21.0):
    - gRPC-Core/Implementation (= 1.21.0)
    - gRPC-Core/Interface (= 1.21.0)
  - gRPC-Core/Implementation (1.21.0):
    - BoringSSL-GRPC (= 0.0.3)
    - gRPC-Core/Interface (= 1.21.0)
    - nanopb (~> 0.3)
  - gRPC-Core/Interface (1.21.0)
  - GTMSessionFetcher/Core (1.2.2)
  - leveldb-library (1.22)
  - nanopb (0.3.901):
    - nanopb/decode (= 0.3.901)
    - nanopb/encode (= 0.3.901)
  - nanopb/decode (0.3.901)
  - nanopb/encode (0.3.901)
  - Protobuf (3.9.2)

DEPENDENCIES:
  - cloud_firestore (from `Pods/.symlinks/plugins/cloud_firestore/ios`)
  - firebase_auth (from `Pods/.symlinks/plugins/firebase_auth/ios`)
  - firebase_core (from `Pods/.symlinks/plugins/firebase_core/ios`)
  - Flutter (from `Pods/.symlinks/flutter/ios`)

SPEC REPOS:
  https://github.com/cocoapods/specs.git:
    - BoringSSL-GRPC
    - Firebase
    - FirebaseAnalytics
    - FirebaseAuth
    - FirebaseAuthInterop
    - FirebaseCore
    - FirebaseCoreDiagnostics
    - FirebaseCoreDiagnosticsInterop
    - FirebaseFirestore
    - FirebaseInstanceID
    - GoogleAppMeasurement
    - GoogleDataTransport
    - GoogleDataTransportCCTSupport
    - GoogleUtilities
    - "gRPC-C++"
    - gRPC-Core
    - GTMSessionFetcher
    - leveldb-library
    - nanopb
    - Protobuf

EXTERNAL SOURCES:
  cloud_firestore:
    :path: Pods/.symlinks/plugins/cloud_firestore/ios
  firebase_auth:
    :path: Pods/.symlinks/plugins/firebase_auth/ios
  firebase_core:
    :path: Pods/.symlinks/plugins/firebase_core/ios
  Flutter:
    :path: Pods/.symlinks/flutter/ios

SPEC CHECKSUMS:
  BoringSSL-GRPC: db8764df3204ccea016e1c8dd15d9a9ad63ff318
  cloud_firestore: 0ac494d23db743f104b95d3291946afec187b74c
  Firebase: 2d750c54cda57d5a6ae31212cfe5cc813c6be7e4
  firebase_auth: 1e3b7bdd37b9fbd4ef75ba1d985b00be09e02d3d
  firebase_core: ae55ea92448ec8675d325da4db22cf3b4d58a54d
  FirebaseAnalytics: 5d9ccbf46ed25d3ec9304d263f85bddf1e93e2d2
  FirebaseAuth: e7f86c2dfc57281cd01f7da5e4b40e01e4510a4a
  FirebaseAuthInterop: 0ffa57668be100582bb7643d4fcb7615496c41fc
  FirebaseCore: 8b2765c445d40db7137989b7146a3aa3f91b5529
  FirebaseCoreDiagnostics: be4f7a09d02ab305f18de59a470412caddb64c2a
  FirebaseCoreDiagnosticsInterop: 6829da2b8d1fc795ff1bd99df751d3788035d2cb
  FirebaseFirestore: 5ee8bdb959541f0d55352f2d681efb03b9742a43
  FirebaseInstanceID: 550df9be1f99f751d8fcde3ac342a1e21a0e6c42
  Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
  GoogleAppMeasurement: 0ae90be1cc4dad40f4a27fc767ef59fa032ec87b
  GoogleDataTransport: c8617c00e4f3eb9418e42ac0e8ac5241a9d555dd
  GoogleDataTransportCCTSupport: 9f352523e8785a71f6754f51eeff09f49ec19268
  GoogleUtilities: 9c2c544202301110b29f7974a82e77fdcf12bf51
  "gRPC-C++": 9dfe7b44821e7b3e44aacad2af29d2c21f7cde83
  gRPC-Core: c9aef9a261a1247e881b18059b84d597293c9947
  GTMSessionFetcher: 61bb0f61a4cb560030f1222021178008a5727a23
  leveldb-library: 55d93ee664b4007aac644a782d11da33fba316f7
  nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
  Protobuf: 67fb42ba613def994e61854de2b3164f13790cc4

PODFILE CHECKSUM: 13dcf421f4da2e937a57e8ba760ed880beae536f

COCOAPODS: 1.7.5
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.9.1+hotfix.2, on Mac OS X 10.14.6 18G95, locale en-CH)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.31.1)
[✓] Connected device (2 available)

• No issues found!
@helenaford
Copy link
Contributor

Consolidating under #1223 - we'll be looking at parsing native error messages & codes and bubbling these up to the Dart layer in a consistent cross-platform format.

@firebase firebase locked and limited conversation to collaborators Aug 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants