owncloud / android

:phone: The ownCloud Android App
GNU General Public License v2.0
3.85k stars 3.06k forks source link

[BUG] App crashes when last account is removed from device's settings #4431

Open jesmrec opened 4 months ago

jesmrec commented 4 months ago

This one comes from https://github.com/owncloud/android/pull/4410#issuecomment-2186212609

Steps:

  1. Add one account to the device
  2. Switch to device settings without closing the app
  3. Accounts -> oC account -> Remove Account
  4. Switch to oC account

Current:

app crashes, this is the stacktrace:

 FATAL EXCEPTION: DefaultDispatcher-worker-15
                 Process: com.owncloud.android.debug, PID: 32604
                 java.lang.NullPointerException: Parameter specified as non-null is null: method com.owncloud.android.data.spaces.datasources.implementation.OCLocalSpacesDataSource$Companion.toModel, parameter <this>
                    at com.owncloud.android.data.spaces.datasources.implementation.OCLocalSpacesDataSource$Companion.toModel(Unknown Source:2)
                    at com.owncloud.android.data.spaces.datasources.implementation.OCLocalSpacesDataSource.getSpaceWithSpecialsByIdForAccount(OCLocalSpacesDataSource.kt:106)
                    at com.owncloud.android.data.spaces.repository.OCSpacesRepository.getSpaceWithSpecialsByIdForAccount(OCSpacesRepository.kt:67)
                    at com.owncloud.android.domain.spaces.usecases.GetSpaceWithSpecialsByIdForAccountUseCase.run(GetSpaceWithSpecialsByIdForAccountUseCase.kt:33)
                    at com.owncloud.android.domain.spaces.usecases.GetSpaceWithSpecialsByIdForAccountUseCase.run(GetSpaceWithSpecialsByIdForAccountUseCase.kt:27)
                    at com.owncloud.android.domain.BaseUseCase.invoke(BaseUseCase.kt:30)
                    at com.owncloud.android.presentation.files.filelist.MainFileListViewModel$updateSpace$1.invokeSuspend(MainFileListViewModel.kt:350)
                    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
                    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
                    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
                    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@75ce667, Dispatchers.IO]
12:08:33.981  E  FATAL EXCEPTION: DefaultDispatcher-worker-18
                 Process: com.owncloud.android.debug, PID: 32604
                 java.lang.NullPointerException: Parameter specified as non-null is null: method com.owncloud.android.data.spaces.datasources.implementation.OCLocalSpacesDataSource$Companion.toModel, parameter <this>
                    at com.owncloud.android.data.spaces.datasources.implementation.OCLocalSpacesDataSource$Companion.toModel(Unknown Source:2)
                    at com.owncloud.android.data.spaces.datasources.implementation.OCLocalSpacesDataSource.getSpaceWithSpecialsByIdForAccount(OCLocalSpacesDataSource.kt:106)
                    at com.owncloud.android.data.spaces.repository.OCSpacesRepository.getSpaceWithSpecialsByIdForAccount(OCSpacesRepository.kt:67)
                    at com.owncloud.android.domain.spaces.usecases.GetSpaceWithSpecialsByIdForAccountUseCase.run(GetSpaceWithSpecialsByIdForAccountUseCase.kt:33)
                    at com.owncloud.android.domain.spaces.usecases.GetSpaceWithSpecialsByIdForAccountUseCase.run(GetSpaceWithSpecialsByIdForAccountUseCase.kt:27)
                    at com.owncloud.android.domain.BaseUseCase.invoke(BaseUseCase.kt:30)
                    at com.owncloud.android.presentation.files.filelist.MainFileListViewModel$updateSpace$1.invokeSuspend(MainFileListViewModel.kt:350)
                    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
                    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
                    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
                    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@b6bac14, Dispatchers.IO]

Expected:

login view displayed with no crash

Pixel 2, Android 11 997ea67d

GeorgeLifinRell commented 2 months ago

I think I can work on that. Assign this to me and will submit a PR asap.

JuancaG05 commented 2 months ago

Hi @GeorgeLifinRell! Thanks for your collaboration! Go for it, no need to have it assigned 😃

jesmrec commented 1 month ago

@GeorgeLifinRell could you finally work on this? if you need any help from our side, just let us know. We are happy to help

GeorgeLifinRell commented 1 month ago

@jesmrec Thank you, I'm working on it, will update asap.

GeorgeLifinRell commented 1 month ago

https://demo.owncloud.org is not working. Is there any alternatives, so that it'll help me a lot.

jesmrec commented 1 month ago

@GeorgeLifinRell

https://demo.owncloud.com katherine/gemini

GeorgeLifinRell commented 1 month ago

I need more info about how to do this, since I'm new to such a huge codebase.

JuancaG05 commented 1 month ago

Hi @GeorgeLifinRell! Well, it's difficult to explain the whole codebase as you said 😉, but my recommendation is first trying to reproduce the problem and get those logs posted in the issue, and from that point, going to the classes indicated in the logs, watching around, trying to identify the problem... At that point, if you have any problem just tell us 😀