Caption and depiction sometimes not set
Example: https://commons.m.wikimedia.org/wiki/File%3AFrench_ambassador_in_Tokyo%2C_Philippe_Setton.jpg
When that happens, the uploaded image does not appear in the contributions activity, I have to swipe down to refresh and make it appear.
When that happens, the uploaded image does not appear in the contributions activity
Had faced this issue when I was testing for https://github.com/commons-app/apps-android-commons/issues/5280, but I don't remember if it was fixed later. The recently added swipe down to refresh functionality fetches the latest list from the server, so I expect it to appear. The two might be related.
You are right, it is most probably the now way this old problem shows up.
Summary for newcomers: For API reasons, upload of an image has two steps:
- Upload the file/description/categories
- Set the captions/depictions
Network issues are inevitable so we should probably:
- Keep half-uploaded images in the "Pending" panel. Visually it is OK if it is the same, making it look different is OK too.
- For these, retry step 2 only. Retry could be implemented the same way as step 1 retry.
One more thing I want to ask, is that when a user initiates an upload and immediately clears the app from memory then does the app continue to upload or queue them and start when the user opens the app? I haven't tried this but just wanted to know if we can force the uploads if not already. However, we'll allow the user to pause and resume the uploads from the notification.
I have a related issue. Captions and Description entered in a non-English language (Malayalam in my case) during upload do not get saved. Screenshot while uploading and from the File information after upload, are attached.
Hi, I'd like to work on this. Can I be assigned?
I looked into it. If setting captions/depicts fails, the error from this call goes to the same catch as a failed upload, so the upload is marked failed even though the file is already on Commons. Next time the app opens it retries failed uploads, the duplicate check finds the file, and the contribution is deleted. So captions and depicts are lost and nothing tells the user. Also depicts runs before captions, so if depicts fails, captions are never sent.
I reproduced this on main with beta by making the depicts call throw. The upload went to Failed, then after reopening the app it was removed with "Contribution already exists" in logcat. The file on beta had no captions or depicts. The example file above looks the same, nothing after the upload.
My plan, same as @nicolas-raoul suggested:
- handle a captions/depicts failure separately from an upload failure
- keep it in Pending and retry only that part, not the upload
- add tests in UploadWorkerTest
@ChinchuC the Malayalam case is a different bug, #6938 (extra language rows weren't saved, so both the ml caption and description were dropped). It was fixed in #6946 a few days ago, so it should work in the next release.
Assigned to you, @Medhansh-741! Thanks!
@nicolas-raoul thanks! Quick check before I start.
My plan is to save the final filename on the contribution right after the file is published (here), before captions/depicts are set. That needs a small DB migration 24→25 adding one column, same as MIGRATION_23_24. If it's set, a retry only redoes captions/depicts (and P18 for nearby uploads) and skips the duplicate check that currently deletes the item (1, 2, 3). On retry it would only add depicts that aren't already there, so nothing gets duplicated.
One question: in your comment you mentioned keeping these in Pending. The simplest way is to leave them in the Failed tab, with the error shown and auto-retried like now. Is that ok for this fix? Moving them to Pending means changing the list and retry logic too, so if you want that I can open a separate issue for it and keep this PR small.
@nicolas-raoul opened #7317 for this.
Compared to my plan above:
- Same: the filename is saved right after the upload (migration 24 to 25), a retry only redoes captions/depicts (and P18), and only depicts that aren't there yet are added.
- Changed: about my question, I kept these uploads in Pending as you suggested, not in Failed, since the file is already on Commons and only captions/depicts are left. They get their own state, so the duplicate check (which only runs for failed uploads) doesn't delete them anymore. I didn't need to change the 3 retry paths for that.
Before/after videos are in the PR.