Skip to content

[cloud_firestore] crashes if you insert "/" char into .document(value) [only iOS] #2338

Description

@mustafarenkci

Describe the bug
im using firestore and it works well but when i try to use a string which contains "/" char into document(), app crashes ONLY ON iOS DEVICES.

For example;

DocumentReference fireStoreReference =
        Firestore.instance.collection('liked').document("xyz**/**xyz");
await fireStoreReference.get().then((DocumentSnapshot ds) async {
***
});

At runtime, the following crash occurs, closing the app (it is not handled by Flutter):

*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff23e3dcce __exceptionPreprocess + 350
	1   libobjc.A.dylib                     0x00007fff50b3b9b2 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff23e3da48 +[NSException raise:format:arguments:] + 88
	3   Foundation                          0x00007fff258ac85b -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
	4   Runner                              0x0000000103b51d77 _ZN8firebase9firestore4util16ObjcThrowHandlerENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 343
	5   Runner                              0x00000001

im using cloud_firestore: ^0.13.4+2

Activity

  1. changed the title [-][cloud_firestore] crashes if you insert "/" char into .document(value)[/-] [+][cloud_firestore] crashes if you insert "/" char into .document(value) [only iOS][/+] on Apr 10, 2020
  2. TahaTesser commented on Apr 14, 2020

    @TahaTesser

    Hi @mustafarenkci
    can you please provide your flutter doctor -v and flutter run --verbose?
    Thank you

  3. mustafarenkci commented on Apr 14, 2020

    @mustafarenkci
    Author

    Hi @mustafarenkci
    can you please provide your flutter doctor -v and flutter run --verbose?
    Thank you

    Here;

    Flutter doctor -v

    [✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E287, locale tr-TR)
        • Flutter version 1.12.13+hotfix.9 at /Users/mustafarenkci/Documents/flutter
        • Framework revision f139b11009 (2 weeks ago), 2020-03-30 13:57:30 -0700
        • Engine revision af51afceb8
        • Dart version 2.7.2
    
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
        • Android SDK at /Users/mustafarenkci/Library/Android/sdk
        • Android NDK location not configured (optional; useful for native profiling support)
        • Platform android-29, build-tools 28.0.3
        • ANDROID_HOME = /Users/mustafarenkci/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 11.4)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 11.4, Build version 11E146
        • CocoaPods version 1.9.1
    
    [✓] Android Studio (version 3.6)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin version 45.1.1
        • Dart plugin version 192.7761
        • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    
    [✓] Connected device (1 available)
        • iPhone 8 • 6090B51F-8963-4F09-8FF8-CA3DE8DA2521 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)
    
    • No issues found!
    

    flutter run --verbose

    [  +12 ms] [DEVICE LOG] 2020-04-15 02:08:52.846210+0300  localhost Runner[15946]: (Foundation) *** Assertion failure in
    firebase::firestore::api::DocumentReference::DocumentReference(model::ResourcePath, std::shared_ptr<Firestore>)(),
    /Users/mustafarenkci/Documents/FlutterProjects/fetvasor/ios/Pods/FirebaseFirestore/Firestore/core/src/firebase/firestore/api/document_reference.cc:67
    [  +63 ms] Service protocol connection closed.
    [        ] Lost connection to device.
    [   +1 ms] DevFS: Deleting filesystem on the device
    (file:///Users/mustafarenkci/Library/Developer/CoreSimulator/Devices/6090B51F-8963-4F09-8FF8-CA3DE8DA2521/data/Containers/Data/Application/E62318B1-B7FC-49CD-9F97-210DE1EA0DA5/tmp/fetvasorjvQZNv/fet
    vasor/)
    [        ] Sending to VM service: _deleteDevFS({fsName: fetvasor})
    [        ] [DEVICE LOG] 2020-04-15 02:08:52.903145+0300  localhost Runner[15946]: (CoreFoundation) *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
    'FIRESTORE INTERNAL ASSERTION FAILED: Invalid document reference. Document references must have an even number of segments, but liked/Abdesti bozan/bozmayan durumlarda farklı mezhepten imam ve
    cemaatin durumu has 3'
    [        ] [DEVICE LOG] *** First throw call stack:
    [        ] [DEVICE LOG] (
    [        ] [DEVICE LOG]         0   CoreFoundation                      0x00007fff23e3dcce __exceptionPreprocess + 350
    [        ] [DEVICE LOG]         1   libobjc.A.dylib                     0x00007fff50b3b9b2 objc_exception_throw + 48
    [        ] [DEVICE LOG]         2   CoreFoundation                      0x00007fff23e3da48 +[NSException raise:format:arguments:] + 88
    [        ] [DEVICE LOG]         3   Foundation                          0x00007fff258ac85b -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
    [        ] [DEVICE LOG]         4   Runner                              0x0000000103943d67
    _ZN8firebase9firestore4util16ObjcThrowHandlerENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 343
    [        ] [DEVICE LOG]         5   Runner                              0x00000001
    [        ] *** First throw call stack:
    [        ] (
    [        ]      0   CoreFoundation                      0x00007fff23e3dcce __exceptionPreprocess + 350
    [        ]      1   libobjc.A.dylib                     0x00007fff50b3b9b2 objc_exception_throw + 48
    [        ]      2   CoreFoundation                      0x00007fff23e3da48 +[NSException raise:format:arguments:] + 88
    [        ]      3   Foundation                          0x00007fff258ac85b -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
    [        ]      4   Runner                              0x0000000103943d67
    _ZN8firebase9firestore4util16ObjcThrowHandlerENS1_13ExceptionTypeEPKcS4_iRKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE + 343
    [        ]      5   Runner                              0x00000001
    [ +252 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not completed
    [   +3 ms] "flutter run" took 398.786ms.
    
    
  4. Ehesp commented on Apr 18, 2020

    @Ehesp
    Member

    .collection('liked').document("xyz**/**xyz");

    A pointer to a document must be an event amount of segments so the error is correct. What happens on Android?

    Collection/Document names cannot include / characters.

  5. onikiri2007 commented on Jun 30, 2020

    @onikiri2007

    I'm getting the same issue. Previous version used to work with the above format even on iOS. On Android, it works as expected.

  6. Ehesp commented on Jul 1, 2020

    @Ehesp
    Member

    On JS, that code produces this error:

    FirebaseError: Invalid document reference. Document references must have an even number of segments, but liked/xyz/xyz has 3
    

    This will be caught but the correct behaviour is to throw an error.

  7. Salakar commented on Jul 7, 2020

    @Salakar
    Contributor

    Hey all, as part of our on-going work for #2582, this has been resolved in our Firebase Firestore rework (#2913) - which has now been merged into master. We'll look at publishing some prereleases in the next few days. Thank you

  8. locked and limited conversation to collaborators on Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    impact: customerA bug with low impact (e.g. affecting only a few customers or has a workaround). (P3)plugin: cloud_firestoretype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions