Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data sync] Can't sync new LOI and data with photos #2614

Closed
gino-m opened this issue Aug 7, 2024 · 2 comments · Fixed by #2617
Closed

[Data sync] Can't sync new LOI and data with photos #2614

gino-m opened this issue Aug 7, 2024 · 2 comments · Fixed by #2617
Assignees
Labels
type: bug Something isn't working

Comments

@gino-m
Copy link
Collaborator

gino-m commented Aug 7, 2024

Collecting data with photo and text tests fails without printing stack trace. Using debugger, I caught the following in LocalMutationSyncWorker:124:

java.lang.ClassCastException: com.google.android.ground.model.submission.TextTaskData cannot be cast to com.google.android.ground.model.submission.PhotoTaskData
	at com.google.android.ground.persistence.remote.firebase.protobuf.ModelToProtoExtKt.toMessage(ModelToProtoExt.kt:170)
	at com.google.android.ground.persistence.remote.firebase.protobuf.ModelToProtoExtKt.createSubmissionMessage(ModelToProtoExt.kt:78)
	at com.google.android.ground.persistence.remote.firebase.schema.SubmissionDocumentReference.addMutationToBatch(SubmissionDocumentReference.kt:35)
	at com.google.android.ground.persistence.remote.firebase.FirestoreDataStore.addSubmissionMutationToBatch(FirestoreDataStore.kt:125)
	at com.google.android.ground.persistence.remote.firebase.FirestoreDataStore.applyMutations(FirestoreDataStore.kt:96)
	at com.google.android.ground.persistence.sync.LocalMutationSyncWorker.processMutations(LocalMutationSyncWorker.kt:118)
	at com.google.android.ground.persistence.sync.LocalMutationSyncWorker.access$processMutations(LocalMutationSyncWorker.kt:43)
	at com.google.android.ground.persistence.sync.LocalMutationSyncWorker$processMutations$2.invokeSuspend(Unknown Source:15)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
@gino-m gino-m added the type: bug Something isn't working label Aug 7, 2024
@gino-m gino-m added this to the Beta release milestone Aug 7, 2024
@gino-m gino-m added this to Ground Aug 7, 2024
@gino-m
Copy link
Collaborator Author

gino-m commented Aug 7, 2024

It appears photo tasks are still being stored in mutations under newTaskData as TextTaskData instead of PhotoTaskData. I suggest fixing at the source and adding a throw/catch to report this in logs.

@shobhitagarwal1612 @scolsen It appears the problem is that ValueJsonConverter still converts photos to TextTaskData when loading from the local db, and only stores the remote path to the local mutation queue. We would also need to full local path to be able to queue up uploads in the media sync worker.

It looks like we have a hack in UserMediaRepository::getLocalFileFromRemotePath to reconstruct the local path to work around this fact.

@gino-m
Copy link
Collaborator Author

gino-m commented Aug 7, 2024

Working around this and filing #2615 to track better fix.

@gino-m gino-m self-assigned this Aug 7, 2024
@gino-m gino-m changed the title [Data sync] Can't sync new LOI and data [Data sync] Can't sync new LOI and data with photos Aug 9, 2024
@gino-m gino-m moved this to Todo in Ground Aug 9, 2024
@gino-m gino-m moved this from Todo to In Progress in Ground Aug 9, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Ground Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant