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

[Bug]: Upload: location categories from different places replace each other, and a failed lookup erases them

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

Summary

When an upload has pictures taken at different places, the app looks up location categories for each place, but it only keeps one list. Each lookup that finishes replaces the categories of the place before it, and a lookup that fails clears them. So the user only sees the location categories of whichever place finished last, or none at all if the last one failed.

Each place's result goes into the same single list in GpsCategoryModel, and the error branch calls clear(): https://github.com/commons-app/apps-android-commons/blob/c025f9e/app/src/main/java/fr/free/nrw/commons/upload/FileProcessor.kt#L226-L234 https://github.com/commons-app/apps-android-commons/blob/c025f9e/app/src/main/java/fr/free/nrw/commons/upload/GpsCategoryModel.kt#L12-L20

Pictures taken at the same place are fine since #7420 looks a place up only once.

Steps to reproduce

  1. Upload 2 or more pictures taken at different places (more than 50 m apart).
  2. Go to the categories step.

Expected behaviour

The location categories of every place are suggested. If one place's lookup fails, the categories of the other places stay.

Actual behaviour

Only the categories of the place whose lookup finished last are suggested. If that lookup failed, there are no location categories at all.

I checked this with two tests on main (c025f9e) in FileProcessorLocationTest, with two places about 110 m apart:

FAIL | pictures from two places show the categories of both | expected:<[CategoryItem: 'Villa Borghese', CategoryItem: 'Pincio']> but was:<[CategoryItem: 'Pincio']>
FAIL | a failed lookup keeps the categories already found at another place | expected:<[CategoryItem: 'Villa Borghese']> but was:<[]>

I also saw it on the phone with two pictures, one tagged in London and one in Delhi (on beta, London has a file in "Emile Garcke", Delhi has files in "New Delhi Railway Station" and "Android sculptures"). Both lookups came back, London first, but the categories step only shows the Delhi ones, no "Emile Garcke".

Device name

OnePlus CPH2491

Android version

Android 16

Commons app version

main at c025f9e (BetaDebug)

Device logs

11-25 23:04:42.327 V/OkHttp: <-- 200 commons.wikimedia.beta.wmcloud.org ... ggscoord=51.510380%7C-0.095580   (London, has Emile Garcke)
11-25 23:04:42.706 V/OkHttp: <-- 200 commons.wikimedia.beta.wmcloud.org ... ggscoord=28.644800%7C77.216721   (Delhi)

Categories step afterwards: New Delhi Railway Station, Android sculptures, no Emile Garcke.

Screenshots

Categories step after uploading the Delhi and London photos together: only Delhi's categories show, no "Emile Garcke".

before-main-two-places

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 17:11 Medhansh-741

Assigned to you, @Medhansh-741! Thanks!

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

@nicolas-raoul opened #7433 for this. Each place's location categories are now added instead of replacing the others, and a failed lookup no longer clears them.

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