question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Firestore] INTERNAL ASSERTION FAILED: Encoded field value should not be null.

See original GitHub issue

Environment

  • Android Studio version: 3.2 RC3
  • Firebase Component: Firestore
  • Component version: 17.1.1

Problem

Occasionally, when creating a new object, I get this:

    java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
        at com.google.firebase.firestore.obfuscated.zzgf.zzb(com.google.firebase:firebase-firestore@@17.1.1:377)
        at com.google.firebase.firestore.obfuscated.zzgk.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.AssertionError: INTERNAL ASSERTION FAILED: Encoded field value should not be null.
        at com.google.firebase.firestore.obfuscated.zzge.zza(com.google.firebase:firebase-firestore@@17.1.1:3046)
        at com.google.firebase.firestore.obfuscated.zzge.zza(com.google.firebase:firebase-firestore@@17.1.1:3031)
        at com.google.firebase.firestore.obfuscated.zzfu.zza(com.google.firebase:firebase-firestore@@17.1.1:262)
        at com.google.firebase.firestore.obfuscated.zzfu.zza(com.google.firebase:firebase-firestore@@17.1.1:957)
        at com.google.firebase.firestore.obfuscated.zzfu.zzb(com.google.firebase:firebase-firestore@@17.1.1:727)
        at com.google.firebase.firestore.obfuscated.zzbf.zza(com.google.firebase:firebase-firestore@@17.1.1:166)
        at com.google.firebase.firestore.obfuscated.zzcy.zzc(com.google.firebase:firebase-firestore@@17.1.1:103)
        at com.google.firebase.firestore.obfuscated.zzcy.zza(com.google.firebase:firebase-firestore@@17.1.1:142)
        at com.google.firebase.firestore.obfuscated.zzbg.zza(com.google.firebase:firebase-firestore@@17.1.1:524)
        at com.google.firebase.firestore.obfuscated.zzbo.run(Unknown Source:6)
        at com.google.firebase.firestore.obfuscated.zzcw.zza(com.google.firebase:firebase-firestore@@17.1.1:150)
        at com.google.firebase.firestore.obfuscated.zzbg.zza(com.google.firebase:firebase-firestore@@17.1.1:514)
        at com.google.firebase.firestore.obfuscated.zzak.zza(com.google.firebase:firebase-firestore@@17.1.1:173)
        at com.google.firebase.firestore.obfuscated.zzk.zza(com.google.firebase:firebase-firestore@@17.1.1:91)
        at com.google.firebase.firestore.obfuscated.zzm.zzb(com.google.firebase:firebase-firestore@@17.1.1:137)
        at com.google.firebase.firestore.obfuscated.zzw.run(Unknown Source:4)
        at com.google.firebase.firestore.obfuscated.zzgf.zzc(com.google.firebase:firebase-firestore@@17.1.1:309)
        at com.google.firebase.firestore.obfuscated.zzgj.call(Unknown Source:2)
        at com.google.firebase.firestore.obfuscated.zzgf.zza(com.google.firebase:firebase-firestore@@17.1.1:285)
        at com.google.firebase.firestore.obfuscated.zzgi.run(Unknown Source:4)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at com.google.firebase.firestore.obfuscated.zzgf$zza.run(com.google.firebase:firebase-firestore@@17.1.1:203)

Due to the codebase it is very hard for me to create a small reproducible sample. What I am doing is creating a new document, while I have a real time query listener. The document is created, so I assume the app crashes when the query listener is notified about it.

I will investigate more, but I could be more helpful if the owners could point me to the right direction. What is this Encoded field value? What could be the issue?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rsgowmancommented, Nov 5, 2018

Firestore encodes/serializes data when either sending it over the network to the backend servers, or when sending it to the local disk. The field values themselves are usually just the document contents, as set by (eg) DocumentReference.set().

So, naively, this could be a Document with data that has somehow become corrupt and failing to serialize before being sent out to the network/disk.

But looking at the stack trace (which, unfortunately, is obfuscated), I can see that this is actually occurring while attempting to encode/serialize the query itself to the local disk. In particular, it looks to be the query’s ‘endAt/endBefore’ field that is causing the exception.

So take a look through your code, and see if you call endAt or endBefore anywhere. If so, take a look at the parameter(s) to those functions and see what the values are. My suspicion, is that the parameters to these functions are somehow being encoded improperly… but I’m not immediately able to come up with something that would cause this. If you can come up with a minimal repro of this problem, I can investigate further.

If you do figure out what’s causing the problem, please let us know! Even if you’re somehow passing invalid data, we should be able to catch that earlier and issue a better error message than this.

0reactions
rsgowmancommented, Nov 30, 2018

FWIW, https://github.com/firebase/firebase-android-sdk/pull/138 “fixes” this such that an exception is thrown much earlier, and is more descriptive of the problem. I’ll close this issue for now; feel free to re-open if there’s something additional you feel should happen here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FIRESTORE INTERNAL ASSERTION FAILED - Stack Overflow
Then your code blows up (per your question). The ! is indicating that's an optional so it could be nil. Best to handle...
Read more >
Google Cloud Firestore Emulator - Go Packages
Package firestore provides a client for reading and writing to a Cloud Firestore database. ... If a value does not exist, an empty...
Read more >
Supported data types | Firestore - Firebase
Null values ; Boolean values; Integer and floating-point values, sorted in numerical order; Date values; Text string values; Byte values; Cloud Firestore ......
Read more >
Security - Appsmith
This error indicates that the application name field has been left empty. This error can be fixed by editing the application name field...
Read more >
Mapping Firestore Data in Swift - The Comprehensive Guide
Data is stored in documents that contain fields mapping to values. ... case .failure(let error): // A Book value could not be initialized ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found