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.

[ToS] App crashes when ToS are missing from db

See original GitHub issue

To Reproduce

  1. Delete the config/tos document from a working Ground Firebase project.
  2. Wipe app data on device and sign back in.

Expected behavior The project list appears.

Actual behavior An exception is thrown:

2021-11-09 18:25:05.731 8390-8390/com.google.android.gnd E/MainViewModel: Error loading terms of service from remote db
    com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
        at com.google.firebase.firestore.util.Util.exceptionFromStatus(Util.java:117)
        at com.google.firebase.firestore.core.EventManager.onError(EventManager.java:166)
        at com.google.firebase.firestore.core.SyncEngine.removeAndCleanupTarget(SyncEngine.java:588)
        at com.google.firebase.firestore.core.SyncEngine.handleRejectedListen(SyncEngine.java:424)
        at com.google.firebase.firestore.core.MemoryComponentProvider$RemoteStoreCallback.handleRejectedListen(MemoryComponentProvider.java:99)
        at com.google.firebase.firestore.remote.RemoteStore.processTargetError(RemoteStore.java:562)
        at com.google.firebase.firestore.remote.RemoteStore.handleWatchChange(RemoteStore.java:446)
        at com.google.firebase.firestore.remote.RemoteStore.access$100(RemoteStore.java:53)
        at com.google.firebase.firestore.remote.RemoteStore$1.onWatchChange(RemoteStore.java:176)
        at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:108)
        at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:38)
        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.lambda$onNext$1$AbstractStream$StreamObserver(AbstractStream.java:119)
        at com.google.firebase.firestore.remote.-$$Lambda$AbstractStream$StreamObserver$IZBnAkL3D_hQ5ofbDpSmX2lhuPo.run(Unknown Source:4)
        at com.google.firebase.firestore.remote.AbstractStream$CloseGuardedRunner.run(AbstractStream.java:67)
        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.onNext(AbstractStream.java:110)
        at com.google.firebase.firestore.remote.FirestoreChannel$1.onMessage(FirestoreChannel.java:125)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:658)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:643)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
        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.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:229)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: io.grpc.StatusException: PERMISSION_DENIED: Missing or insufficient permissions.
        at io.grpc.Status.asException(Status.java:541)
        at com.google.firebase.firestore.util.Util.exceptionFromStatus(Util.java:115)
        at com.google.firebase.firestore.core.EventManager.onError(EventManager.java:166) 
        at com.google.firebase.firestore.core.SyncEngine.removeAndCleanupTarget(SyncEngine.java:588) 
        at com.google.firebase.firestore.core.SyncEngine.handleRejectedListen(SyncEngine.java:424) 
        at com.google.firebase.firestore.core.MemoryComponentProvider$RemoteStoreCallback.handleRejectedListen(MemoryComponentProvider.java:99) 
        at com.google.firebase.firestore.remote.RemoteStore.processTargetError(RemoteStore.java:562) 
        at com.google.firebase.firestore.remote.RemoteStore.handleWatchChange(RemoteStore.java:446) 
        at com.google.firebase.firestore.remote.RemoteStore.access$100(RemoteStore.java:53) 
        at com.google.firebase.firestore.remote.RemoteStore$1.onWatchChange(RemoteStore.java:176) 
        at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:108) 
        at com.google.firebase.firestore.remote.WatchStream.onNext(WatchStream.java:38) 
        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.lambda$onNext$1$AbstractStream$StreamObserver(AbstractStream.java:119) 
        at com.google.firebase.firestore.remote.-$$Lambda$AbstractStream$StreamObserver$IZBnAkL3D_hQ5ofbDpSmX2lhuPo.run(Unknown Source:4) 
        at com.google.firebase.firestore.remote.AbstractStream$CloseGuardedRunner.run(AbstractStream.java:67) 
        at com.google.firebase.firestore.remote.AbstractStream$StreamObserver.onNext(AbstractStream.java:110) 
        at com.google.firebase.firestore.remote.FirestoreChannel$1.onMessage(FirestoreChannel.java:125) 
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:658) 
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:643) 
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) 
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) 
        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.util.AsyncQueue$SynchronizedShutdownAwareExecutor$DelayedStartFactory.run(AsyncQueue.java:229) 
        at java.lang.Thread.run(Thread.java:764) 

Subsequent logins result in a white screen with no errors logged.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
gino-mcommented, Nov 12, 2021

Hi @shobhitagarwal1612, it looks this is related to #1026 and possibly a pre-existing error:

  • config/tos is optional, and the DataStore methods that retrieve it return a Maybe. I don’t understand why an error is returned if the document is missing rather than Maybe.empty(); maybe empty is returned only when the collection exists but the document is missing, but an error is returned when the collection doesn’t exist? Might be worth looking into.
  • FirebaseFirestoreException.CODE UNAVAILABLE isn’t specific to THE config, but the error message seems to imply it is

Could you PTAL?

0reactions
gino-mcommented, Nov 10, 2021

@atalekar Thanks! A few answers:

Crashing isn’t the worst thing to do if a legal requirement is failing.

The ToS is optional, so if the ToS isn’t present the app should proceed to the project list after sign-in; not all deployments require a custom ToS.

Example server temp down - person by passes consent - later when server is back on the user is able to access the app without ever having given consent.

A network connection is required for the sign-in and join project flows. The ToS is part of the sign-in flow, so it’s assumed the device is online. If it’s not, the sign-in flow should fail and return the user to the sign-in screen.

@rachaprince The ToS shouldn’t be required; our other pilot projects own their own Firebase instance, and as such have already agreed to the Firebase ToS.

I think there are two issues at play here: 1) why are we receiving “PERMISSION_DENIED” for ToS when it doesn’t exist - likely an issue with our firestore.rules and 2) why does the app fail silently on subsequent login attempts. Thanks for offering to help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TOS iOS app crashes : r/thinkorswim - Reddit
The TOS apps on my iPhone and iPad won't open anymore. They immediately crash. Does anyone else have this experience? I'm running the...
Read more >
Android app crashes when made some changes in database
I have developed an android app which consists of database.When i install it on mobile it works fine for first time. when i...
Read more >
Technical - thinkorswim Learning Center
My thinkorswim® platform is constantly 'reconnecting. ' What can I do? If you are connected wirelessly, you can start troubleshooting by shutting the...
Read more >
Detect and diagnose crashes - Android Developers
Once you have identified that your app is reporting crashes, the next step is to diagnose them. Solving crashes can be difficult. However,...
Read more >
App crashes after using useQuery or Realm.objects()
When I perform a query to list the data that are in the database through the useQuery(MyModel) command, the data is apparently loaded...
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