Page MenuHomePhabricator

Some users can't favourite collections in My Library
Closed, ResolvedPublic

Description

Some users on de.wiki have reported that the collection favouriting button is not working for them on Firefox / MacOS: https://de.wikipedia.org/wiki/Wikipedia_Diskussion:F%C3%B6rderung/The_Wikipedia_Library#Favoriten-Funktion_defekt?

X HR POSThttps://wikipedialibrary.wmflabs.org/users/favorite_collection/[HTTP/2 500 Internal Server Error 243ms]
Uncaught TypeError: response.response JSON is undefined my_library:9850:17
error https://wikipedialibrary.wmflabs.org/users/my_library/:9850
    jQuery 6
    favoriteCollection https://wikipedialibrary.wmflabs.org/users/my_library/:9805
    on click https://wikipedialibrary.wmflabs.org/users/my_library/:1

Event Timeline

I've tested this on Chrome and Firefox on MacOS and can't reproduce the issue.

This error is telling us that we have a condition where we're not forming the favorite request data correctly. I think it's going to be correlated to editor accounts. It should be a straightforward bug to fix if we can get a couple of impacted editor handles.

This error is telling us that we have a condition where we're not forming the favorite request data correctly. I think it's going to be correlated to editor accounts. It should be a straightforward bug to fix if we can get a couple of impacted editor handles.

The two editors reporting this issue are Polarlys and Aschmidt,

@jsn.sherman Would you please let me know if there is anything I can do to help find the issue.

Okay, I can see what the issue here; the impacted users have unavailable partners for which they have no authorization in their favorites list. The favorites list gets validated as a whole, not per item that's added/removed. When we delete authorizations for partners that are no longer available, the references are still left in the favorites list, which then fails validation upon save. This is why nothing can be changed.

I'm working on a fix now.

Okay, I have a quick fix here:
https://github.com/WikipediaLibrary/TWLight/pull/1115

it would probably be "most correct" to also create a signal to modify those favorite partner sets to remove unauthorized partners when their authorizations get deleted, but this is a low risk change that should solve the user-facing problem.

I updated the validator so that it only checks the new partners being added instead of the whole set and verified that it fixes the problem and passes current tests.

@Aschmidt and/or @Fehufanga
I have the patch running on our staging environment, which I just synced up with the live site. You should find that favoriting/unfavoriting now works. Feel free to test it out and let us know if it solves your issue:
https://twlight-staging.wmflabs.org/users/my_library/

@jsn.sherman Thanks for the fix! I've tried it out in Firefox on macOS, and it works.

There is one inconsistency, though. When I remove a favourite, it disappears instantly from the list. However, when I add a favourite I have to reload the page in order to make it appear on the favourites tab. Is there still something you could do about this? Thanks, again!

@Aschmidt thanks for checking: that's not expected behavior so I'll take a look!

I verified that it's working as it was before on my non-impacted account (no reload required to add favorites), so I'll need to create the initial problem (leftover hidden favorite from unavailable partner) on my staging account to try to reproduce the issue.

@Aschmidt is that reload issue persistent? I've verified that my staging account has the same underlying state as yours, and I'm not able to reproduce the issue with Firefox on Android or Linux. The only quirk I noticed was that I had to scroll down to see newly added partners on mobile due to the way they are added in dynamically; partners were sorted properly on a fresh page load.

Maybe @Samwalton9 can check on MacOS? On staging, you'll need to add something to your favorites and then delete the authorization. You can now see the favorites attached to user profiles in admin to verify the state. Then just try adding and removing partners from favorites.

Tested on Chrome on MacOS. Favouriting works immediately for me (the number increments and the authorization is visible in the Favorites tab). Per @jsn.sherman, however, new favorites are placed at the end of the list and are only alphabetised on a page reload. This is a separate issue that I recall being a side effect of the technical implementation when we first added favoriting.

To test further I:

  • Applied for Adam Matthew (a LINK partner) on my volunteer account (doesn't have coordinator/staff rights)
  • Got approved for it via staff account
  • It showed up in My Library, and I favourited it.
  • I marked Adam Matthew as Not Available from staff account
  • Adam Matthew is still shown in My Collections and Favorites, but is marked Not Available.
  • Using my staff account I manually deleted the Adam Matthew authorization via /admin
  • Adam Matthew is still shown in My Collections and Favorites, still marked Not Available. I've double checked the authorization is no longer present. Maybe the My Library cache doesn't clear on auth deletion? It's not a workflow we do in prod.
  • Logging out and back in removed Adam Matthew from my Favorites.
  • Adding and removing favorites works as it did previously.
  • I outright deleted the Adam Matthew partner and everything still seems fine.
  • I applied for Berg Fashion Library and approved myself.
  • It appeared in My Library and I favorited it.
  • I moved Berg to the Library Bundle
  • Berg remained in Favorites and I can still add/remove favorites as expected.

Favouriting works immediately for me (the number increments and the authorization is visible in the Favorites tab). Per @jsn.sherman, however, new favorites are placed at the end of the list and are only alphabetised on a page reload.

Thanks for further testing, @Samwalton9 ! Same here in Firefox. With me, too, new favourites appear at the end of the list. I'm not sure whether that was the case yesterday because I did not realise something happend to the end of the favourites list.

However, basic adding and removing of favourites works, So, thanks, again, @jsn.sherman !

@Aschmidt If you could check one more time on the production site that would be very helpful and I can close this as resolved!

@Samwalton9 , thanks for pinging. :) I think, it's alright now. I also posted a notice on German Wikipedia where the issue came up: https://de.wikipedia.org/wiki/Wikipedia_Diskussion:F%C3%B6rderung/The_Wikipedia_Library#Favoriten-Funktion_defekt? So, if you would like to close the task, please go ahead!