Repository: streetcomplete/StreetComplete (language: kotlin)

Issue:
Element is not updated after conflict on upload
In building mode: after the building has been selected, it does not change color. You have to make the entry again so that the building is displayed as an apartment building, for example. 

**How to Reproduce**
 Go into the building mode, select a building and change the building type to an apartment building. After the confirmation, the building type is not displayed.

**Expected Behavior**
The apartment building is displayed after the confirmation



Discussion hints:
I can't reproduce this problem with version 58.2. Can you record a screen video?
Yes, of course. 
https://github.com/user-attachments/assets/539079f2-46d6-4a2c-a093-144cfa2c84db


Thanks! This might be another instance of #5545. Can you try to reproduce it another time and then immediately after go to Menu -> About -> Show Logs, then change the filter to show only the logs around the time this bug happened and share these here?

Alternatively, if you remember exactly when you reproduced this issue, i.e. apparently today at 16:12, you can also skip trying to reproduce it another time and directly look for the logs at that time.
I hope the screenshots will help you

![Screenshot_20240715_171921_StreetComplete](https://github.com/user-attachments/assets/c0291be1-13d5-440b-ab08-658562c59b17)
![Screenshot_20240715_171907_StreetComplete](https://github.com/user-attachments/assets/aea174a2-9e91-4549-8e40-78eeacf94086)

You can also press the share button, it would be much easier for me. (Do select the time range first in the filter dialog)
2024-07-15T16:04:38.065: I [Preloader] Loaded country boundaries in 0.2s
2024-07-15T16:04:38.438: I [Preloader] Loaded features dictionary in 0.6s
2024-07-15T16:04:38.439: I [Preloader] Preloading data took 0.6s
2024-07-15T16:04:38.792: W [ChangesetManager] Couldn't close changeset #153969903 because it has already been closed
2024-07-15T16:04:38.912: I [Upload] Starting upload
2024-07-15T16:04:38.922: I [Upload] Finished upload
2024-07-15T16:04:39.063: D [OsmAvatarsDownload] Downloaded file: /data/user/0/de.westnordost.streetcomplete/cache/osm_user_avatars/6319200
2024-07-15T16:04:39.135: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8071982,10.0288599
2024-07-15T16:04:39.735: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:09:32.120: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8071982,10.0288599
2024-07-15T16:09:32.136: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:09:32.253: I [Upload] Starting upload
2024-07-15T16:09:32.375: I [Upload] Finished upload
2024-07-15T16:09:32.499: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8071875,10.0288713
2024-07-15T16:09:32.518: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:09:33.309: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8072517,10.0288983
2024-07-15T16:09:33.331: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:09:45.211: D [ElementEditsController] Add BuildingsOverlay for WAY#397687166
2024-07-15T16:09:45.249: D [OsmQuestController] AddRoofShape requires surrounding map data to determine applicability to WAY#397687166
2024-07-15T16:09:45.299: I [Upload] Starting upload
2024-07-15T16:09:45.326: D [OsmQuestController] Created AddBuildingLevels for WAY#397687166
2024-07-15T16:09:45.326: D [OsmQuestController] Created AddRoofShape for WAY#397687166
2024-07-15T16:09:45.677: I [OsmQuestController] Created 2 quests for 1 updated elements in 443ms
2024-07-15T16:09:45.689: I [ChangesetManager] Created changeset #153974585
2024-07-15T16:09:45.697: I [OsmQuestController] Persisted 2 new and removed 1 already resolved quests in 0.0s
2024-07-15T16:09:45.793: D [ElementEditsUploader] Uploaded a UpdateElementTagsAction
2024-07-15T16:09:45.858: I [Upload] Finished upload
2024-07-15T16:09:52.885: D [ElementEditsController] Add BuildingsOverlay for WAY#397687186
2024-07-15T16:09:52.897: D [OsmQuestController] AddRoofShape requires surrounding map data to determine applicability to WAY#397687186
2024-07-15T16:09:52.899: D [OsmQuestController] Created AddBuildingLevels for WAY#397687186
2024-07-15T16:09:52.899: D [OsmQuestController] Created AddRoofShape for WAY#397687186
2024-07-15T16:09:52.934: I [Upload] Starting upload
2024-07-15T16:09:52.961: I [OsmQuestController] Created 2 quests for 1 updated elements in 67ms
2024-07-15T16:09:52.974: I [OsmQuestController] Persisted 2 new and removed 1 already resolved quests in 0.0s
2024-07-15T16:09:53.172: D [ElementEditsUploader] Dropped a UpdateElementTagsAction: Conflict while applying the changes
2024-07-15T16:09:53.189: D [OsmQuestController] Created AddBuildingType for WAY#397687186
2024-07-15T16:09:53.225: I [OsmQuestController] Created 1 quests for 1 updated elements in 40ms
2024-07-15T16:09:53.232: I [OsmQuestController] Persisted 1 new and removed 2 already resolved quests in 0.0s
2024-07-15T16:09:53.314: I [Upload] Finished upload
2024-07-15T16:12:46.390: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8072517,10.0288983
2024-07-15T16:12:46.426: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:12:46.912: I [Upload] Starting upload
2024-07-15T16:12:46.935: I [Upload] Finished upload
2024-07-15T16:12:47.185: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8074556,10.0287353
2024-07-15T16:12:47.221: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:12:48.408: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8073517,10.0287767
2024-07-15T16:12:48.440: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:12:53.136: D [ElementEditsController] Add BuildingsOverlay for WAY#397687189
2024-07-15T16:12:53.181: D [OsmQuestController] AddRoofShape requires surrounding map data to determine applicability to WAY#397687189
2024-07-15T16:12:53.189: D [OsmQuestController] Created AddRoofShape for WAY#397687189
2024-07-15T16:12:53.189: D [OsmQuestController] Created AddBuildingLevels for WAY#397687189
2024-07-15T16:12:53.296: I [Upload] Starting upload
2024-07-15T16:12:53.747: I [OsmQuestController] Created 2 quests for 1 updated elements in 575ms
2024-07-15T16:12:53.799: I [OsmQuestController] Persisted 2 new and removed 1 already resolved quests in 0.1s
2024-07-15T16:12:54.051: D [ElementEditsUploader] Dropped a UpdateElementTagsAction: Conflict while applying the changes
2024-07-15T16:12:54.109: D [OsmQuestController] Created AddBuildingType for WAY#397687189
2024-07-15T16:12:54.162: I [OsmQuestController] Created 1 quests for 1 updated elements in 90ms
2024-07-15T16:12:54.171: I [OsmQuestController] Persisted 1 new and removed 2 already resolved quests in 0.0s
2024-07-15T16:12:54.265: I [Upload] Finished upload
2024-07-15T16:12:59.176: D [ElementEditsController] Add BuildingsOverlay for WAY#397687189
2024-07-15T16:12:59.209: D [OsmQuestController] AddRoofShape requires surrounding map data to determine applicability to WAY#397687189
2024-07-15T16:12:59.212: D [OsmQuestController] Created AddBuildingLevels for WAY#397687189
2024-07-15T16:12:59.213: D [OsmQuestController] Created AddRoofShape for WAY#397687189
2024-07-15T16:12:59.272: I [Upload] Starting upload
2024-07-15T16:12:59.286: I [OsmQuestController] Created 2 quests for 1 updated elements in 91ms
2024-07-15T16:12:59.313: I [OsmQuestController] Persisted 2 new and removed 1 already resolved quests in 0.0s
2024-07-15T16:12:59.427: D [ElementEditsUploader] Uploaded a UpdateElementTagsAction
2024-07-15T16:12:59.475: I [Upload] Finished upload
2024-07-15T16:14:48.104: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8073517,10.0287767
2024-07-15T16:14:48.123: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:14:48.316: I [Upload] Starting upload
2024-07-15T16:14:48.345: I [Upload] Finished upload
2024-07-15T16:14:49.426: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8072617,10.0287117
2024-07-15T16:14:49.454: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:50:40.629: I [Preloader] Loaded country boundaries in 0.2s
2024-07-15T16:50:41.067: I [Preloader] Loaded features dictionary in 0.7s
2024-07-15T16:50:41.067: I [Preloader] Preloading data took 0.7s
2024-07-15T17:13:52.089: I [Preloader] Loaded country boundaries in 0.2s
2024-07-15T17:13:52.751: I [Preloader] Loaded features dictionary in 0.9s
2024-07-15T17:13:52.752: I [Preloader] Preloading data took 0.9s
2024-07-15T17:13:52.809: W [ChangesetManager] Couldn't close changeset #153974585 because it has already been closed
2024-07-15T17:13:52.967: I [Upload] Starting upload
2024-07-15T17:13:52.976: I [Upload] Finished upload
2024-07-15T17:13:53.006: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8071934,10.0288643
2024-07-15T17:13:53.058: D [OsmAvatarsDownload] Downloaded file: /data/user/0/de.westnordost.streetcomplete/cache/osm_user_avatars/6319200
2024-07-15T17:13:53.660: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T17:14:03.452: D [ElementEditsController] Add BuildingsOverlay for WAY#397687197
2024-07-15T17:14:03.481: D [OsmQuestController] AddRoofShape requires surrounding map data to determine applicability to WAY#397687197
2024-07-15T17:14:03.535: I [Upload] Starting upload
2024-07-15T17:14:03.560: D [OsmQuestController] Created AddBuildingLevels for WAY#397687197
2024-07-15T17:14:03.560: D [OsmQuestController] Created AddRoofShape for WAY#397687197
2024-07-15T17:14:03.874: I [OsmQuestController] Created 2 quests for 1 updated elements in 405ms
2024-07-15T17:14:03.876: I [ChangesetManager] Created changeset #153977305
2024-07-15T17:14:03.888: I [OsmQuestController] Persisted 2 new and removed 1 already resolved quests in 0.0s
2024-07-15T17:14:04.044: D [ElementEditsUploader] Dropped a UpdateElementTagsAction: Conflict while applying the changes
2024-07-15T17:14:04.078: D [OsmQuestController] Created AddBuildingType for WAY#397687197
2024-07-15T17:14:04.139: I [OsmQuestController] Created 1 quests for 1 updated elements in 72ms
2024-07-15T17:14:04.146: I [OsmQuestController] Persisted 1 new and removed 2 already resolved quests in 0.0s
2024-07-15T17:14:04.216: I [Upload] Finished upload
2024-07-15T17:14:09.508: D [ElementEditsController] Add BuildingsOverlay for WAY#397687197
2024-07-15T17:14:09.527: D [OsmQuestController] AddRoofShape requires surrounding map data to determine applicability to WAY#397687197
2024-07-15T17:14:09.529: D [OsmQuestController] Created AddBuildingLevels for WAY#397687197
2024-07-15T17:14:09.529: D [OsmQuestController] Created AddRoofShape for WAY#397687197
2024-07-15T17:14:09.566: I [Upload] Starting upload
2024-07-15T17:14:09.570: I [OsmQuestController] Created 2 quests for 1 updated elements in 45ms
2024-07-15T17:14:09.582: I [OsmQuestController] Persisted 2 new and removed 1 already resolved quests in 0.0s
2024-07-15T17:14:09.726: D [ElementEditsUploader] Uploaded a UpdateElementTagsAction
2024-07-15T17:14:09.759: I [Upload] Finished upload
2024-07-15T17:22:07.925: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8071934,10.0288643
2024-07-15T17:22:08.152: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8072514,10.0285792
2024-07-15T17:22:08.176: I [Upload] Starting upload
2024-07-15T17:22:08.491: I [Upload] Finished upload
2024-07-15T17:22:09.245: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T17:22:09.259: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T17:22:25.573: D [ElementEditsController] Add BuildingsOverlay for WAY#397967546
2024-07-15T17:22:25.596: D [OsmQuestController] AddRoofShape requires surrounding map data to determine applicability to WAY#397967546
2024-07-15T17:22:25.600: D [OsmQuestController] Created AddBuildingLevels for WAY#397967546
2024-07-15T17:22:25.600: D [OsmQuestController] Created AddRoofShape for WAY#397967546
2024-07-15T17:22:25.635: I [Upload] Starting upload
2024-07-15T17:22:25.952: I [OsmQuestController] Created 2 quests for 1 updated elements in 359ms
2024-07-15T17:22:25.966: I [OsmQuestController] Persisted 2 new and removed 1 already resolved quests in 0.0s
2024-07-15T17:22:26.349: D [ElementEditsUploader] Dropped a UpdateElementTagsAction: Conflict while applying the changes
2024-07-15T17:22:26.394: D [OsmQuestController] Created AddBuildingType for WAY#397967546
2024-07-15T17:22:26.442: I [OsmQuestController] Created 1 quests for 1 updated elements in 69ms
2024-07-15T17:22:26.449: I [OsmQuestController] Persisted 1 new and removed 2 already resolved quests in 0.0s
2024-07-15T17:22:26.513: I [Upload] Finished upload
2024-07-15T17:22:33.177: D [ElementEditsController] Add BuildingsOverlay for WAY#397967541
2024-07-15T17:22:33.203: D [OsmQuestController] AddRoofShape requires surrounding map data to determine applicability to WAY#397967541
2024-07-15T17:22:33.206: D [OsmQuestController] Created AddBuildingLevels for WAY#397967541
2024-07-15T17:22:33.206: D [OsmQuestController] Created AddRoofShape for WAY#397967541
2024-07-15T17:22:33.230: I [Upload] Starting upload
2024-07-15T17:22:33.264: I [OsmQuestController] Created 2 quests for 1 updated elements in 71ms
2024-07-15T17:22:33.281: I [OsmQuestController] Persisted 2 new and removed 1 already resolved quests in 0.0s
2024-07-15T17:22:33.472: D [ElementEditsUploader] Dropped a UpdateElementTagsAction: Conflict while applying the changes
2024-07-15T17:22:33.501: D [OsmQuestController] Created AddBuildingType for WAY#397967541
2024-07-15T17:22:33.538: I [OsmQuestController] Created 1 quests for 1 updated elements in 46ms
2024-07-15T17:22:33.545: I [OsmQuestController] Persisted 1 new and removed 2 already resolved quests in 0.0s
2024-07-15T17:22:33.609: I [Upload] Finished upload
2024-07-15T17:22:37.392: D [ElementEditsController] Add BuildingsOverlay for WAY#397967536
2024-07-15T17:22:37.416: D [OsmQuestController] AddRoofShape requires surrounding map data to determine applicability to WAY#397967536
2024-07-15T17:22:37.417: D [OsmQuestController] Created AddBuildingLevels for WAY#397967536
2024-07-15T17:22:37.417: D [OsmQuestController] Created AddRoofShape for WAY#397967536
2024-07-15T17:22:37.457: I [OsmQuestController] Created 2 quests for 1 updated elements in 50ms
2024-07-15T17:22:37.462: I [Upload] Starting upload
2024-07-15T17:22:37.469: I [OsmQuestController] Persisted 2 new and removed 1 already resolved quests in 0.0s
2024-07-15T17:22:37.656: D [ElementEditsUploader] Dropped a UpdateElementTagsAction: Conflict while applying the changes
2024-07-15T17:22:37.672: D [OsmQuestController] Created AddBuildingType for WAY#397967536
2024-07-15T17:22:37.712: I [OsmQuestController] Created 1 quests for 1 updated elements in 43ms
2024-07-15T17:22:37.720: I [OsmQuestController] Persisted 1 new and removed 2 already resolved quests in 0.0s
2024-07-15T17:22:37.790: I [Upload] Finished upload
2024-07-15T17:23:01.630: D [ElementEditsController] Add WayLitOverlay for WAY#24146588
2024-07-15T17:23:01.654: D [OsmQuestController] AddMaxHeight requires surrounding map data to determine applicability to WAY#24146588
2024-07-15T17:23:01.662: D [OsmQuestController] Created AddRoadSurface for WAY#24146588
2024-07-15T17:23:01.689: I [Upload] Starting upload
2024-07-15T17:23:01.710: I [OsmQuestController] Created 1 quests for 1 updated elements in 63ms
2024-07-15T17:23:01.718: I [OsmQuestController] Persisted 1 new and removed 0 already resolved quests in 0.0s
2024-07-15T17:23:01.887: I [ChangesetManager] Created changeset #153977710
2024-07-15T17:23:02.008: D [ElementEditsUploader] Uploaded a UpdateElementTagsAction
2024-07-15T17:23:02.050: I [Upload] Finished upload
2024-07-15T17:23:35.752: D [ElementEditsController] Add WayLitOverlay for WAY#34123872
2024-07-15T17:23:35.773: D [OsmQuestController] AddMaxHeight requires surrounding map data to determine applicability to WAY#34123872
2024-07-15T17:23:35.778: D [OsmQuestController] Created AddCycleway for WAY#34123872
2024-07-15T17:23:35.778: D [OsmQuestController] Created AddSidewalk for WAY#34123872
2024-07-15T17:23:35.778: D [OsmQuestController] Created AddRoadSmoothness for WAY#34123872
2024-07-15T17:23:35.818: I [OsmQuestController] Created 3 quests for 1 updated elements in 46ms
2024-07-15T17:23:35.827: I [OsmQuestController] Persisted 3 new and removed 1 already resolved quests in 0.0s
2024-07-15T17:23:35.870: I [Upload] Starting upload
2024-07-15T17:23:36.012: D [ElementEditsUploader] Uploaded a UpdateElementTagsAction
2024-07-15T17:23:36.056: I [Upload] Finished upload
2024-07-15T17:23:41.573: D [ElementEditsController] Add WayLitOverlay for WAY#555383320
2024-07-15T17:23:41.590: D [OsmQuestController] AddMaxHeight requires surrounding map data to determine applicability to WAY#555383320
2024-07-15T17:23:41.593: D [OsmQuestController] Created AddCycleway for WAY#555383320
2024-07-15T17:23:41.593: D [OsmQuestController] Created AddSidewalk for WAY#555383320
2024-07-15T17:23:41.594: D [OsmQuestController] Created AddLanes for WAY#555383320
2024-07-15T17:23:41.594: D [OsmQuestController] Created AddRoadSmoothness for WAY#555383320
2024-07-15T17:23:41.643: I [Upload] Starting upload
2024-07-15T17:23:41.656: I [OsmQuestController] Created 4 quests for 1 updated elements in 67ms
2024-07-15T17:23:41.671: I [OsmQuestController] Persisted 4 new and removed 1 already resolved quests in 0.0s
2024-07-15T17:23:41.786: D [ElementEditsUploader] Uploaded a UpdateElementTagsAction
2024-07-15T17:23:41.837: I [Upload] Finished upload
2024-07-15T17:23:45.020: D [ElementEditsController] Add WayLitOverlay for WAY#555383323
2024-07-15T17:23:45.033: D [OsmQuestController] AddMaxHeight requires surrounding map data to determine applicability to WAY#555383323
2024-07-15T17:23:45.035: D [OsmQuestController] Created AddCycleway for WAY#555383323
2024-07-15T17:23:45.036: D [OsmQuestController] Created AddSidewalk for WAY#555383323
2024-07-15T17:23:45.036: D [OsmQuestController] Created AddLanes for WAY#555383323
2024-07-15T17:23:45.036: D [OsmQuestController] Created AddRoadSmoothness for WAY#555383323
2024-07-15T17:23:45.080: I [OsmQuestController] Created 4 quests for 1 updated elements in 49ms
2024-07-15T17:23:45.089: I [OsmQuestController] Persisted 4 new and removed 1 already resolved quests in 0.0s
2024-07-15T17:23:45.094: I [Upload] Starting upload
2024-07-15T17:23:45.192: D [ElementEditsUploader] Uploaded a UpdateElementTagsAction
2024-07-15T17:23:45.223: I [Upload] Finished upload
2024-07-15T17:33:34.425: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8072514,10.0285792
2024-07-15T17:33:34.470: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T17:33:34.965: I [Upload] Starting upload
2024-07-15T17:33:34.990: I [Upload] Finished upload
2024-07-15T17:33:36.470: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8080067,10.0291950
2024-07-15T17:33:36.519: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (9 tiles)
Thank you!
The relevant section should be this, as in the video one can see that the issue was reproduced 16:12.

```
2024-07-15T16:12:46.390: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8072517,10.0288983
2024-07-15T16:12:46.426: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:12:46.912: I [Upload] Starting upload
2024-07-15T16:12:46.935: I [Upload] Finished upload
2024-07-15T16:12:47.185: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8074556,10.0287353
2024-07-15T16:12:47.221: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:12:48.408: I [QuestAutoSyncer] Checking whether to automatically download new quests at 48.8073517,10.0287767
2024-07-15T16:12:48.440: I [QuestAutoSyncer] All downloaded in radius of 472 meters around user (12 tiles)
2024-07-15T16:12:53.136: D [ElementEditsController] Add BuildingsOverlay for WAY#397687189
2024-07-15T16:12:53.181: D [OsmQuestController] AddRoofShape requires surrounding map data to determine applicability to WAY#397687189
2024-07-15T16:12:53.189: D [OsmQuestController] Created AddRoofShape for WAY#397687189
2024-07-15T16:12:53.189: D [OsmQuestController] Created AddBuildingLevels for WAY#397687189
2024-07-15T16:12:53.296: I [Upload] Starting upload
2024-07-15T16:12:53.747: I [OsmQuestController] Created 2 quests for 1 updated elements in 575ms
2024-07-15T16:12:53.799: I [OsmQuestController] Persisted 2 new and removed 1 already resolved quests in 0.1s
2024-07-15T16:12:54.051: D [ElementEditsUploader] Dropped a UpdateElementTagsAction: Conflict while applying the changes
2024-07-15T16:12:54.109: D [OsmQuestController] Created AddBuildingType for WAY#397687189
2024-07-15T16:12:54.162: I [OsmQuestController] Created 1 quests for 1 updated elements in 90ms
2024-07-15T16:12:54.171: I [OsmQuestController] Persisted 1 new and removed 2 already resolved quests in 0.0s
2024-07-15T16:12:54.265: I [Upload] Finished upload
2024-07-15T16:12:59.176: D [ElementEditsController] Add BuildingsOverlay for WAY#397687189
2024-07-15T16:12:59.209: D [OsmQuestController] AddRoofShape requires surrounding map data to determine applicability to WAY#397687189
2024-07-15T16:12:59.212: D [OsmQuestController] Created AddBuildingLevels for WAY#397687189
2024-07-15T16:12:59.213: D [OsmQuestController] Created AddRoofShape for WAY#397687189
2024-07-15T16:12:59.272: I [Upload] Starting upload
2024-07-15T16:12:59.286: I [OsmQuestController] Created 2 quests for 1 updated elements in 91ms
2024-07-15T16:12:59.313: I [OsmQuestController] Persisted 2 new and removed 1 already resolved quests in 0.0s
2024-07-15T16:12:59.427: D [ElementEditsUploader] Uploaded a UpdateElementTagsAction
2024-07-15T16:12:59.475: I [Upload] Finished upload
```

And the error happens here:
```
2024-07-15T16:12:54.051: D [ElementEditsUploader] Dropped a UpdateElementTagsAction: Conflict while applying the changes
```

When you create an edit, by default, it is immediately uploaded to OpenStreetMap. If a conflict occurs during upload, your change will be discarded because the assumption is that the data you just edited has been edited by someone else in the meantime and thus the premise under which the quest (etc.) has been created might not even be correct anymore.

It looks like the building you edited was https://www.openstreetmap.org/way/397687189/history

And it looks like that just three hours before you edited the building, someone else (Hello, @mcliquid ! The world is small!) also edited the same property. Judging by that all these buildings are displayed in red, I conclude that StreetComplete downloaded the area when these buildings were still tagged with `building=yes`.

So, it looks like in the end it is absolutely the correct behavior to refuse your edit.

Now, a few open questions, though:

- If a conflict is detected, the **current** version of the element should be downloaded and persisted locally and subsequently be displayed. This does not seem to be happening here, as the display of the building reverts to being red (=`building=yes`)

- If a conflict is detected, IIRC, it should be triggered that the whole area is downloaded again to prevent any further conflicts. This does not seem to be happening here. Or is the map data just marked as being to-be-refreshed?
Yes, I confess that after checking changesets using OsmCha, I found several individual terraced houses in my area with `building=terrace`. I then changed these to `building=house` and `house=terraced` and then changed all the buildings to which this applies in JOSM at once. It seems obvious that I was too quick with that correction.

But I would say it's a good idea to re-download the data if this occurs.
@Helium314 you mentioned recently you would have a look into this, but I assume that you have all hands full at the moment with the merge, right?
Currently I'm a little occupied by trying to make SCEE run again, but I think I'll wait with re-implementing broken features until the main screen is switched to compose...
So I might have time a little sooner.
My plan was to first get the v59.0 alpha (i.e. release on github but no beta-release on google play) ready before finishing my work on composing the controls etc. on the main screen (it's not everything on the main screen, not the bottom sheet, not the map. Just the controls, edit history sidebar). Getting v59-alpha1 ready entails for me 1. rummaging through the issue tracker a bit more and fixing small things, especially stuff requiring translations and 2. dev-testing the version a bit to see and fix if there are any obvious issues with maplibre.

Whether or not I will also squeeze mainscreen-compose into v59.0 I am not sure yet. I understand it would be more convenient for you if I put that into v59, too?
> it's not everything on the main screen, not the bottom sheet, not the map. Just the controls, edit history sidebar

Oh, then I'll need to do the fixes anyway. I'm not even sure whether there is anything related to those controls that needs fixing.
So then I'd gain (almost) nothing from putting more compose work into 59.0.
The area seems to be invalidated correctly. The element is updated correctly with the new tags. But the overlay displays red, instead of the new value.
The overlay is updated correctly on reloading (e.g. switching overlay and back again).
When adding some logging, it looks like [`nothingChanged`](https://github.com/streetcomplete/StreetComplete/blob/master/app/src/main/java/de/westnordost/streetcomplete/data/osm/edits/MapDataWithEditsSource.kt#L102-L107) is true, so update of quests and overlays is not triggered.
In more detail:
1. upload fails
2. edit is deleted (`elementEditsController.markSyncFailed`), which triggers creation of quests for initial element
3. the updated element is downloaded
4. updates are persisted in the database (`mapDataController.updateAll`)
5. `MapDataWithEditsSource.onUpdated` is called. None of the local changes refers to the updated element, so nothing is changed and listeners (quest controller and overlay manager) are not informed about the update. This is because the download of a single element was not considered in #4472 

A workaround (fix?) could be calling `markSyncFailed` only after updating map data, but I didn't check whether this might create other issues.
Hmm, I was about to write: no, because if the edit is still around when `onUpdated` is called, it will be applied on top of the freshly downloaded data for display and then the display doesn't change.

But if the upload fails due to a conflict, the "faulty" edit should also produce a conflict when trying to apply it locally onto the the updated data and hence is not applied.

So, moving markSyncFailed in ElementEditsUploader below the map data update might just work! But this must be tested, of course.
But wait, isn't there a simpler solution? The `elementsThatMightHaveChangedByKey` checks seem to be missing one important part:

Checking whether there's any element in `updated` that isn't in any of `updateElementes` or `deletedElements` yet. And to me, this sounds like a bug right now.
So if `updated.any { it.key !in updatedElements }` then `nothingChanged` must be false?

Pull request: callOnUpdated if an updated element does not have a local edit
Fixes #5745 as in the latest comments.
(the new test fails without the changes to `MapDataWithEditsSource`)

Test command: ./gradlew :app:testDebugUnitTest --tests "de.westnordost.streetcomplete.data.osm.edits.MapDataWithEditsSourceTest"

Fix patch:
diff --git a/app/src/main/java/de/westnordost/streetcomplete/data/osm/edits/MapDataWithEditsSource.kt b/app/src/main/java/de/westnordost/streetcomplete/data/osm/edits/MapDataWithEditsSource.kt
index 8b1a2c5c064..4d003048b92 100644
--- a/app/src/main/java/de/westnordost/streetcomplete/data/osm/edits/MapDataWithEditsSource.kt
+++ b/app/src/main/java/de/westnordost/streetcomplete/data/osm/edits/MapDataWithEditsSource.kt
@@ -78,14 +78,16 @@ class MapDataWithEditsSource internal constructor(
             val modifiedDeleted = ArrayList<ElementKey>()
             synchronized(this) {
                 /* We don't want to callOnUpdated if none of the changes affects map data provided
-                 * by MapDataWithEditsSource.
+                 * by MapDataWithEditsSource
                  * This is the case if
                  *  * All keys in deleted are already in deletedElements.
                  *  * The modified versions of all elements in updated are the same before and after
                  *    rebuildLocalChanges, except for the timestamp (expected to have few ms
                  *    difference) and version (never updated locally).
+                 *   * No new elements are being added
                  */
                 val deletedIsUnchanged = deletedElements.containsAll(deleted)
+                val hasNewElements = updated.any { it.key !in updatedElements }
                 val elementsThatMightHaveChangedByKey = updated.mapNotNull { element ->
                     val key = element.key
                     if (element.isEqualExceptVersionAndTimestamp(updatedElements[key])) {
@@ -99,7 +101,7 @@ class MapDataWithEditsSource internal constructor(
 
                 /* nothingChanged can be false at this point when e.g. there are two edits on the
                    same element, and onUpdated is called after the first edit is uploaded. */
-                val nothingChanged = deletedIsUnchanged && elementsThatMightHaveChangedByKey.all {
+                val nothingChanged = deletedIsUnchanged && !hasNewElements && elementsThatMightHaveChangedByKey.all {
                     val updatedElement = get(it.first.type, it.first.id)
                     // old and new elements are equal except version and timestamp, or both are null
                     it.second?.isEqualExceptVersionAndTimestamp(updatedElement) ?: (updatedElement == null)


Test patch:
diff --git a/app/src/test/java/de/westnordost/streetcomplete/data/osm/edits/MapDataWithEditsSourceTest.kt b/app/src/test/java/de/westnordost/streetcomplete/data/osm/edits/MapDataWithEditsSourceTest.kt
index 422a3577c76..11cc5e7e7d8 100644
--- a/app/src/test/java/de/westnordost/streetcomplete/data/osm/edits/MapDataWithEditsSourceTest.kt
+++ b/app/src/test/java/de/westnordost/streetcomplete/data/osm/edits/MapDataWithEditsSourceTest.kt
@@ -1222,6 +1222,29 @@ class MapDataWithEditsSourceTest {
         verify(listener).onUpdated(eq(updatedMapData), eq(emptyList()))
     }
 
+    @Test
+    fun `does call onUpdated when updated element is not in local changes`() {
+        val nd = node(1, p(0.1, 0.0))
+        val ndModified = node(1, p(0.3, 0.0))
+        val nd2 = node(2, p(0.5, 0.4))
+        val p2 = ElementGeometryEntry(NODE, 2, pGeom(0.5, 0.4))
+
+        originalElementsAre(nd, nd2)
+        mapDataChangesAre(modifications = listOf(ndModified))
+
+        val s = create()
+        val listener = mock<MapDataWithEditsSource.Listener>()
+        s.addListener(listener)
+
+        val updatedMapData = MutableMapDataWithGeometry(
+            elements = listOf(nd2),
+            geometryEntries = listOf(p2)
+        )
+        mapDataListener.onUpdated(updatedMapData, emptyList())
+
+        verify(listener).onUpdated(eq(updatedMapData), eq(emptyList()))
+    }
+
     //endregion
 
     //region MapDataController.Listener ::onReplacedForBBox