Firestore: NoSuchElementException in SQLiteIndexManager.encodeValues for a != query with a trailing orderBy when cache index auto-creation is enabled
Maintainer thường phản hồi trong vòng 1 ngày
@dconeybe đang làm issue này rồi.
Từ ngày 13/11/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
[READ] Step 1: Are you in the right place?
Yes, this is a crash inside the Firestore SDK.
[REQUIRED] Step 2: Describe your environment
- Android Studio version: not relevant (runtime crash)
- Firebase Component: Firestore
- Component version: 26.0.2 (Firebase BoM 34.5.0)
- Devices: Pixel 9 (Android 17), Android emulator (sdk_gphone64_arm64)
[REQUIRED] Step 3: Describe the problem
After calling persistentCacheIndexManager.enableIndexAutoCreation(), the app crashes with Internal error in Cloud Firestore (26.0.2) when a snapshot listener is attached to a query that has equality filters, a != filter, and an additional orderBy after the != field.
Steps to reproduce:
- Enable persistent cache index auto-creation.
- Attach a snapshot listener to a query of the shape below, against a collection with enough cached documents for the SDK to auto-create an index for it (the query scans at least 100 local documents and more than twice the number it returns).
- The next time the query runs it is served from that index, and the app crashes.
java.lang.RuntimeException: Internal error in Cloud Firestore (26.0.2).
at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$3 (AsyncQueue.java:546)
Caused by: java.util.NoSuchElementException
at java.util.LinkedHashMap$LinkedHashIterator.nextNode (LinkedHashMap.java:1062)
at java.util.LinkedHashMap$LinkedValueIterator.next (LinkedHashMap.java:1089)
at com.google.firebase.firestore.local.SQLiteIndexManager.encodeValues (SQLiteIndexManager.java:744)
at com.google.firebase.firestore.local.SQLiteIndexManager.getDocumentsMatchingTarget (SQLiteIndexManager.java:540)
at com.google.firebase.firestore.local.QueryEngine.performQueryUsingIndex (QueryEngine.java:179)
at com.google.firebase.firestore.local.QueryEngine.getDocumentsMatchingQuery (QueryEngine.java:101)
at com.google.firebase.firestore.local.LocalStore.executeQuery (LocalStore.java:878)
at com.google.firebase.firestore.core.SyncEngine.initializeViewAndComputeSnapshot (SyncEngine.java:223)
at com.google.firebase.firestore.core.SyncEngine.listen (SyncEngine.java:210)
at com.google.firebase.firestore.core.EventManager.addQueryListener (EventManager.java:142)
at com.google.firebase.firestore.core.FirestoreClient.lambda$listen$7 (FirestoreClient.java:176)
Analysis: Target.getNotInValues(fieldIndex) returns as soon as it reaches the != / not-in segment ("NotIn/NotEqual is always a suffix"), so the returned collection holds one value per segment up to and including that field. SQLiteIndexManager.encodeValues() then calls position.next() once for every directional segment of the index. When the index has a segment after the != field (here the second orderBy), the iterator is exhausted and next() throws.
Impact: Fatal and not catchable by the app: it is thrown on Firestore's worker thread and AsyncQueue rethrows it on the main thread. The index is persisted, so the crash repeats every time the query runs, even after index auto-creation is turned off again, until the cache indexes are deleted. 10 crashes across three installs in two days of internal testing.
Expected: the query runs, either using the index or falling back to a full scan.
Relevant Code:
Firebase.firestore.persistentCacheIndexManager?.enableIndexAutoCreation()
collection
.whereEqualTo("a", valueA)
.whereEqualTo("b", valueB)
.whereEqualTo("c", valueC)
.whereNotEqualTo("score", null)
.orderBy("score", Query.Direction.DESCENDING)
.orderBy("createdAt", Query.Direction.ASCENDING)
.limit(1)
.snapshots()
- Ngôn ngữ chính
- Java
- Star
- 2.6k
- Fork
- 733
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 72
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firebase/firebase-android-sdk
-
api: remoteconfig
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
firebase/firebase-android-sdk#8827 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Crashlytics plugin writes build ID lists in directory listing order, so APKs can differ between machinesCó thể đã có người làm @mrober đã nhận 8 ngày trước. Đang mởapi: crashlytics
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
firebase/firebase-android-sdk#8789 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
api: auth
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
firebase/firebase-android-sdk#8505 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
firebase/firebase-android-sdk#8835 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
firebase/firebase-android-sdk#8832 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của firebase/firebase-android-sdk
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
NationalSecurityAgency/ghidra#10220 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
RIS export splits an organization name containing “and” into multiple authorsCó thể đã có người làm @Gautam-aman đã nhận hôm nay. Đang mởstatus: needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
JabRef/jabref#17821 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
FailureContext.java rounds down thresholds in lastedAtLeast()Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày