firebase-ios-sdk: FIRESTORE INTERNAL ASSERTION FAILED: Trying to compare documents on fields that don't exist. (expected value1.has_value() && value2.has_value())

[REQUIRED] Step 1: Describe your environment

  • Xcode version:13.1
  • Firebase SDK version:8.10.0
  • Installation method: CocoaPods
  • Firebase Component: Auth, Core, Database, Firestore, Messaging, Storage
  • Target platform(s): iOS

[REQUIRED] Step 2: Describe the problem

Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0x9904c __exceptionPreprocess 1 libobjc.A.dylib 0x15f54 objc_exception_throw 2 Foundation 0x130834 -[NSMutableDictionary(NSMutableDictionary) initWithContentsOfFile:] 3 FirebaseFirestore 0x44868 (Missing) 4 FirebaseFirestore 0x44348 (Missing) 5 FirebaseFirestore 0x914b4 (Missing) 6 FirebaseFirestore 0x91554 (Missing) 7 FirebaseFirestore 0xd88a4 (Missing) 8 FirebaseFirestore 0xdf468 (Missing) 9 FirebaseFirestore 0x3b84c (Missing) 10 FirebaseFirestore 0x40650 (Missing) 11 FirebaseFirestore 0x40470 (Missing) 12 FirebaseFirestore 0x38920 (Missing) 13 FirebaseFirestore 0x38528 (Missing) 14 FirebaseFirestore 0x3836c (Missing) 15 FirebaseFirestore 0x121fec (Missing) 16 FirebaseFirestore 0x10bd58 (Missing) 17 FirebaseFirestore 0x10b860 (Missing) 18 FirebaseFirestore 0x68b18 (Missing) 19 FirebaseFirestore 0x5b40 (Missing) 20 FirebaseFirestore 0x1169c0 (Missing) 21 libdispatch.dylib 0x4660 _dispatch_client_callout 22 libdispatch.dylib 0xbde4 _dispatch_lane_serial_drain 23 libdispatch.dylib 0xc958 _dispatch_lane_invoke 24 libdispatch.dylib 0x171a8 _dispatch_workloop_worker_thread 25 libsystem_pthread.dylib 0x10f4 _pthread_wqthread 26 libsystem_pthread.dylib 0xe94 start_wqthread

Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0x129754 __exceptionPreprocess 1 libobjc.A.dylib 0x287a8 objc_exception_throw 2 CoreFoundation 0x2b3f8 -[CFPrefsSearchListSource addManagedSourceForIdentifier:user:] 3 Foundation 0xd0a6c -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] 4 FirebaseFirestore 0x44868 (Missing) 5 FirebaseFirestore 0x44348 (Missing) 6 FirebaseFirestore 0x914b4 (Missing) 7 FirebaseFirestore 0x91554 (Missing) 8 FirebaseFirestore 0xd88a4 (Missing) 9 FirebaseFirestore 0xdf468 (Missing) 10 FirebaseFirestore 0x3b84c (Missing) 11 FirebaseFirestore 0x40650 (Missing) 12 FirebaseFirestore 0x40470 (Missing) 13 FirebaseFirestore 0x38920 (Missing) 14 FirebaseFirestore 0x38528 (Missing) 15 FirebaseFirestore 0x3836c (Missing) 16 FirebaseFirestore 0x121fec (Missing) 17 FirebaseFirestore 0x10bd58 (Missing) 18 FirebaseFirestore 0x10b860 (Missing) 19 FirebaseFirestore 0x68b18 (Missing) 20 FirebaseFirestore 0x5b40 (Missing) 21 FirebaseFirestore 0x1169c0 (Missing) 22 libdispatch.dylib 0x481c _dispatch_client_callout 23 libdispatch.dylib 0xc004 _dispatch_lane_serial_drain 24 libdispatch.dylib 0xcc00 _dispatch_lane_invoke 25 libdispatch.dylib 0x174bc _dispatch_workloop_worker_thread 26 libsystem_pthread.dylib 0x37a4 _pthread_wqthread 27 libsystem_pthread.dylib 0xa74c start_wqthread

Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0x12a5f0 __exceptionPreprocess 1 libobjc.A.dylib 0x5bcc objc_exception_throw 2 CoreFoundation 0x2d7bc +[_CFXNotificationTokenRegistration keyCallbacks] 3 Foundation 0xd5134 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] 4 FirebaseFirestore 0x44868 (Missing) 5 FirebaseFirestore 0x44348 (Missing) 6 FirebaseFirestore 0x914b4 (Missing) 7 FirebaseFirestore 0x91554 (Missing) 8 FirebaseFirestore 0xd88a4 (Missing) 9 FirebaseFirestore 0xdf468 (Missing) 10 FirebaseFirestore 0x3b84c (Missing) 11 FirebaseFirestore 0x40650 (Missing) 12 FirebaseFirestore 0x40470 (Missing) 13 FirebaseFirestore 0x38920 (Missing) 14 FirebaseFirestore 0x38528 (Missing) 15 FirebaseFirestore 0x3836c (Missing) 16 FirebaseFirestore 0x121fec (Missing) 17 FirebaseFirestore 0x10bd58 (Missing) 18 FirebaseFirestore 0x10b860 (Missing) 19 FirebaseFirestore 0x68b18 (Missing) 20 FirebaseFirestore 0x5b40 (Missing) 21 FirebaseFirestore 0x1169c0 (Missing) 22 libdispatch.dylib 0x5b524 _dispatch_client_callout 23 libdispatch.dylib 0x38b3c _dispatch_lane_serial_drain$VARIANT$armv81 24 libdispatch.dylib 0x3954c _dispatch_lane_invoke$VARIANT$armv81 25 libdispatch.dylib 0x4284c _dispatch_workloop_worker_thread 26 libsystem_pthread.dylib 0xbb74 _pthread_wqthread 27 libsystem_pthread.dylib 0xe740 start_wqthread

Steps to reproduce:

Three different crash log added above but all occurred on same condition. Basically crash happened when user update firestore document field value to “nil” while force close the app.

Relevant Code:

let fieldValue:Int? = nil let updatedMap = [“number_field”: fieldValue] Firestore.firestore().collection(“users”) .document(String(120)) .setData(updatedMap as [String : Any], merge: true)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 50 (24 by maintainers)

Most upvoted comments

@igorvoytovich Thanks for the info. That gives a pretty strong indicator that the crash is fixed. I’ll wait for @sspogra to reply to see if the crash resolution is confirmed.

@igorvoytovich Thanks for the updated stack trace. My guess is that my fix #9550 fixed the original crash, and now it’s gotten past the point where it was previously crashing and is now crashing in a different place. Since it’s not clear, I’d like to treat it as a new issue. Would you mind opening a new issue with this new stack trace? Even if it’s related, it’s going to require its own investigation.

Also, you mentioned in your older comment (https://github.com/firebase/firebase-ios-sdk/issues/9258#issuecomment-1024736997) that you were getting “hundreds” of reports of the old crash. Do you still get any reports of the old stack trace after upgrading to 8.15.0? Or are all of your crashes this “new” stack trace since upgrading to 8.15.0?

@dconeybe App still not updated on app store with new firebase version. For now you can close this issue, I will comment here when my app was live on store.

@dconeybe I will check this only when app release to app store. Our app will be release within 10 days. After that i can provide you feedback.

Hello @dconeybe Updated stack trace

Fatal Exception: NSInternalInconsistencyException
FIRESTORE INTERNAL ASSERTION FAILED: Trying to compare documents on fields that don't exist; field_path=__name__, lhs=users/16451, rhs=users/16451, value1.has_value()=false, value2.has_value()=false
0
CoreFoundation
__exceptionPreprocess
2
Foundation
-[NSMutableDictionary(NSMutableDictionary) initWithContentsOfFile:]
3
FirebaseFirestore
exception_apple.mm - Line 59
firebase::firestore::util::ObjcThrowHandler(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 59
4
FirebaseFirestore
exception.cc - Line 97
firebase::firestore::util::Throw(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 97
5
FirebaseFirestore
hard_assert.cc - Line 42
firebase::firestore::util::internal::FailAssertion(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*) + 42
6
FirebaseFirestore
order_by.cc - Line 62
firebase::firestore::core::OrderBy::Compare(firebase::firestore::model::Document const&, firebase::firestore::model::Document const&) const + 62
7
FirebaseFirestore
query.cc - Line 289
std::__1::__function::__func<firebase::firestore::core::Query::Comparator() const::$_0, std::__1::allocator<firebase::firestore::core::Query::Comparator() const::$_0>, firebase::firestore::util::ComparisonResult (firebase::firestore::model::Document const&, firebase::firestore::model::Document const&)>::operator()(firebase::firestore::model::Document const&, firebase::firestore::model::Document const&) + 289
8
FirebaseFirestore
find_if.h - Line 28
firebase::firestore::immutable::impl::ArraySortedMap<firebase::firestore::model::Document, firebase::firestore::util::Empty, firebase::firestore::model::DocumentComparator>::find(firebase::firestore::model::Document const&) const + 28
9
FirebaseFirestore
array_sorted_map.h - Line 216
firebase::firestore::immutable::impl::ArraySortedMap<firebase::firestore::model::Document, firebase::firestore::util::Empty, firebase::firestore::model::DocumentComparator>::erase(firebase::firestore::model::Document const&) const + 216
10
FirebaseFirestore
sorted_map.h - Line 371
firebase::firestore::immutable::SortedMap<firebase::firestore::model::Document, firebase::firestore::util::Empty, firebase::firestore::model::DocumentComparator>::erase(firebase::firestore::model::Document const&) const + 371
11
FirebaseFirestore
sorted_set.h - Line 51
firebase::firestore::immutable::SortedSet<firebase::firestore::model::Document, firebase::firestore::model::DocumentComparator>::erase(firebase::firestore::model::Document const&) const + 51
12
FirebaseFirestore
document_set.h - Line 137
firebase::firestore::model::DocumentSet::erase(firebase::firestore::model::DocumentKey const&) const + 137
13
FirebaseFirestore
optional.h - Line 428
firebase::firestore::model::DocumentSet::insert(absl::lts_2020_02_25::optional<firebase::firestore::model::Document> const&) const + 428
14
FirebaseFirestore
view.cc - Line 198
firebase::firestore::core::View::ComputeDocumentChanges(firebase::firestore::immutable::SortedMap<firebase::firestore::model::DocumentKey, firebase::firestore::model::Document, firebase::firestore::util::Comparator<firebase::firestore::model::DocumentKey> > const&, absl::lts_2020_02_25::optional<firebase::firestore::core::ViewDocumentChanges> const&) const + 198
15
FirebaseFirestore
sync_engine.cc - Line 475
firebase::firestore::core::SyncEngine::EmitNewSnapshotsAndNotifyLocalStore(firebase::firestore::immutable::SortedMap<firebase::firestore::model::DocumentKey, firebase::firestore::model::Document, firebase::firestore::util::Comparator<firebase::firestore::model::DocumentKey> > const&, absl::lts_2020_02_25::optional<firebase::firestore::remote::RemoteEvent> const&) + 475
16
FirebaseFirestore
sync_engine.cc - Line 212
firebase::firestore::core::SyncEngine::WriteMutations(std::__1::vector<firebase::firestore::model::Mutation, std::__1::allocator<firebase::firestore::model::Mutation> >&&, std::__1::function<void (firebase::firestore::util::Status)>) + 212
17
FirebaseFirestore
function.h - Line 463
std::__1::__function::__func<firebase::firestore::core::FirestoreClient::WriteMutations(std::__1::vector<firebase::firestore::model::Mutation, std::__1::allocator<firebase::firestore::model::Mutation> >&&, std::__1::function<void (firebase::firestore::util::Status)>)::$_15, std::__1::allocator<firebase::firestore::core::FirestoreClient::WriteMutations(std::__1::vector<firebase::firestore::model::Mutation, std::__1::allocator<firebase::firestore::model::Mutation> >&&, std::__1::function<void (firebase::firestore::util::Status)>)::$_15>, void ()>::operator()() + 463
18
FirebaseFirestore
atomic - Line 997
firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&) + 997
19
FirebaseFirestore
function.h - Line 491
firebase::firestore::util::Task::ExecuteAndRelease() + 491
20
libdispatch.dylib
_dispatch_client_callout
25
libsystem_pthread.dylib
start_wqthread

This is the raw stack trace we are seeing on version 8.13.0

NSInternalInconsistencyException: Application threw exception NSInternalInconsistencyException: FIRESTORE INTERNAL ASSERTION FAILED: Trying to compare documents on fields that don't exist; field_path=__name__, lhs=classes/vLp84zTO474mi31RyQLy, rhs=classes/vLp84zTO474mi31RyQLy, value1.has_value()=false, value2.has_value()=false
0 CoreFoundation 0x129708 __exceptionPreprocess + 220
1 libobjc.A.dylib 0x287a8 objc_exception_throw + 60
2 CoreFoundation 0x2b3b8 -[CFPrefsSearchListSource addManagedSourceForIdentifier:user:]
3 Foundation 0xd181c -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 108
4 FirebaseFirestore 0x4684c firebase::firestore::util::ObjcThrowHandler(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 284
5 FirebaseFirestore 0x4632c firebase::firestore::util::Throw(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 20
6 FirebaseFirestore 0x939b0 firebase::firestore::util::internal::FailAssertion(char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*)
7 FirebaseFirestore 0xec3e0 firebase::firestore::core::OrderBy::Compare(firebase::firestore::model::Document const&, firebase::firestore::model::Document const&) const + 784
8 FirebaseFirestore 0xf3b44 std::__1::__function::__func<firebase::firestore::core::Query::Comparator() const:😒_0, std::__1::allocator<firebase::firestore::core::Query::Comparator() const:😒_0>, firebase::firestore::util::ComparisonResult(firebase::firestore::model::Document const&, firebase::firestore::model::Document const&)>::operator()(firebase::firestore::model::Document const&, firebase::firestore::model::Document const&) + 60
9 FirebaseFirestore 0x42860 firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty> firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty>::InnerErasefirebase::firestore::model::DocumentComparator(firebase::firestore::model::Document const&, firebase::firestore::model::DocumentComparator const&) const + 124
10 FirebaseFirestore 0x42950 firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty> firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty>::InnerErasefirebase::firestore::model::DocumentComparator(firebase::firestore::model::Document const&, firebase::firestore::model::DocumentComparator const&) const + 364
11 FirebaseFirestore 0x428e8 firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty> firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty>::InnerErasefirebase::firestore::model::DocumentComparator(firebase::firestore::model::Document const&, firebase::firestore::model::DocumentComparator const&) const + 260
12 FirebaseFirestore 0x42950 firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty> firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty>::InnerErasefirebase::firestore::model::DocumentComparator(firebase::firestore::model::Document const&, firebase::firestore::model::DocumentComparator const&) const + 364
13 FirebaseFirestore 0x428e8 firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty> firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty>::InnerErasefirebase::firestore::model::DocumentComparator(firebase::firestore::model::Document const&, firebase::firestore::model::DocumentComparator const&) const + 260
14 FirebaseFirestore 0x42950 firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty> firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty>::InnerErasefirebase::firestore::model::DocumentComparator(firebase::firestore::model::Document const&, firebase::firestore::model::DocumentComparator const&) const + 364
15 FirebaseFirestore 0x428e8 firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty> firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty>::InnerErasefirebase::firestore::model::DocumentComparator(firebase::firestore::model::Document const&, firebase::firestore::model::DocumentComparator const&) const + 260
16 FirebaseFirestore 0x428e8 firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty> firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty>::InnerErasefirebase::firestore::model::DocumentComparator(firebase::firestore::model::Document const&, firebase::firestore::model::DocumentComparator const&) const + 260
17 FirebaseFirestore 0x42778 firebase::firestore::immutable::impl::TreeSortedMap<firebase::firestore::model::Document, firebase::firestore::util::Empty, firebase::firestore::model::DocumentComparator>::erase(firebase::firestore::model::Document const&) const + 40
18 FirebaseFirestore 0x4242c firebase::firestore::immutable::SortedMap<firebase::firestore::model::Document, firebase::firestore::util::Empty, firebase::firestore::model::DocumentComparator>::erase(firebase::firestore::model::Document const&) const + 152
19 FirebaseFirestore 0x3a994 firebase::firestore::immutable::SortedSet<firebase::firestore::model::Document, firebase::firestore::model::DocumentComparator>::erase(firebase::firestore::model::Document const&) const + 48
20 FirebaseFirestore 0x3a5c4 firebase::firestore::model::DocumentSet::erase(firebase::firestore::model::DocumentKey const&) const + 104
21 FirebaseFirestore 0x3a414 firebase::firestore::model::DocumentSet::insert(absl::lts_2020_02_25::optionalfirebase::firestore::model::Document const&) const + 84
22 FirebaseFirestore 0x13650c firebase::firestore::core::View::ComputeDocumentChanges(firebase::firestore::immutable::SortedMap<firebase::firestore::model::DocumentKey, firebase::firestore::model::Document, firebase::firestore::util::Comparatorfirebase::firestore::model::DocumentKey > const&, absl::lts_2020_02_25::optionalfirebase::firestore::core::ViewDocumentChanges const&) const + 2828
23 FirebaseFirestore 0x120634 firebase::firestore::core::SyncEngine::EmitNewSnapshotsAndNotifyLocalStore(firebase::firestore::immutable::SortedMap<firebase::firestore::model::DocumentKey, firebase::firestore::model::Document, firebase::firestore::util::Comparatorfirebase::firestore::model::DocumentKey > const&, absl::lts_2020_02_25::optionalfirebase::firestore::remote::RemoteEvent const&) + 300
24 FirebaseFirestore 0x121894 firebase::firestore::core::SyncEngine::ApplyRemoteEvent(firebase::firestore::remote::RemoteEvent const&) + 408
25 FirebaseFirestore 0x10a4d4 firebase::firestore::remote::RemoteStore::RaiseWatchSnapshot(firebase::firestore::model::SnapshotVersion const&) + 2688
26 FirebaseFirestore 0x142efc firebase::firestore::remote::WatchStream::NotifyStreamResponse(grpc::ByteBuffer const&) + 332
27 FirebaseFirestore 0x11a600 firebase::firestore::remote::Stream::OnStreamRead(grpc::ByteBuffer const&) + 240
28 FirebaseFirestore 0x86860 std::__1::__function::__func<firebase::firestore::remote::GrpcCompletion::Complete(bool):😒_0, std::__1::allocatorfirebase::firestore::remote::GrpcCompletion::Complete(bool)::$_0, void ()>::operator()() + 56
29 FirebaseFirestore 0x7f54 firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&) + 68
30 FirebaseFirestore 0x12af20 firebase::firestore::util::Task::ExecuteAndRelease() + 184
31 libdispatch.dylib 0x481c _dispatch_client_callout + 20
32 libdispatch.dylib 0xc004 _dispatch_lane_serial_drain + 620
33 libdispatch.dylib 0xcc00 _dispatch_lane_invoke + 404
34 libdispatch.dylib 0x174bc _dispatch_workloop_worker_thread + 764
35 libsystem_pthread.dylib 0x37a4 _pthread_wqthread + 276
36 libsystem_pthread.dylib 0xa74c start_wqthread

@sspogra The improvement of the error message has been incorporated into version 8.12.1 of the iOS SDK, released on February 10, 2022. When you get a chance, upgrade your dependency to this new version and provide updated stack traces and error messages.