apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

[Bug]: Upload: one failed caption search hides all category suggestions

Open Medhansh-741 opened this issue 1 week ago • 2 comments

Summary

On the categories step of an upload, the app looks up suggestions for each picture's caption. If just one of those lookups fails (a timeout, a 429, no connection for a moment), all suggestions disappear: the ones from the other captions, from the depictions, from the location, and even the recent categories that come from the phone itself. The user gets "Error occurred while loading categories." instead.

The suggestions are combined in CategoriesModel.suggestionsOrSearch with combineLatest, and each caption is searched in titleCategories / getTitleCategories with no error handling, so one error fails the whole list: https://github.com/commons-app/apps-android-commons/blob/caa5c9d/app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.kt#L120-L127 https://github.com/commons-app/apps-android-commons/blob/caa5c9d/app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.kt#L314-L329

The error then goes to showLoadError in CategoriesPresenter: https://github.com/commons-app/apps-android-commons/blob/caa5c9d/app/src/main/java/fr/free/nrw/commons/upload/categories/CategoriesPresenter.kt#L74-L86

Typed search already handles this: categoriesMatching turns a failed search into an empty list with onErrorReturnItem(emptyList()), so one bad search doesn't break the others.

Steps to reproduce

  1. Upload 2 or more pictures with different captions.
  2. Make one caption search fail (for example a 429 from the API, or a dropped connection during that request).
  3. Go to the categories step.

Expected behaviour

The suggestions that did load are shown (other captions, depictions, location, recent categories). Only the failed caption's suggestions are missing.

Actual behaviour

No suggestions at all, and "Error occurred while loading categories." is shown.

I checked this with a unit test on main (caa5c9d): two captions, one search returns results and the other fails with an HTTP 429, plus one recent category. searchAll returns no suggestions and only the error:

FAIL | one failed caption search does not remove the other suggestions | java.lang.AssertionError: Error(s) present: [java.lang.Exception: HTTP 429] (latch = 0, values = 0, errors = 1, completions = 0)

Device name

Found in the code and a unit test, not on a device yet

Android version

n/a

Commons app version

main at caa5c9d

Would you like to work on the issue?

Yes

@nicolas-raoul could you set the type to Bug? I can't set it from my side.

Medhansh-741 avatar Nov 25 '26 12:11 Medhansh-741

Assigned to you, @Medhansh-741! Thanks!

nicolas-raoul avatar Nov 25 '26 12:11 nicolas-raoul

@nicolas-raoul opened #7430 for this. A failed caption search now just gives no results for that caption, so the other suggestions still show.

Medhansh-741 avatar Nov 25 '26 13:11 Medhansh-741