Unable to unfavorite badge

I’m trying to unfavorite both of my favorited badges, however, everytime I try to unfavorite the Hot Link badge, I get a consistent Http 400 error:

image

This has been happening for a few days now, as far as I’m aware.


I tried doing this on my mobile device instead, but I get the same error.


Edit: Marked as unsolved again since this issue still occurs for some people

27 Likes

Issue is still occurring

14 Likes

I was finally able to resolve the issue. I don’t know why it was happening, but I favorited another badge then unfavorited the Hot Link badge and the problem was gone (didn’t fix it before)

9 Likes

I’m still experiencing this issue and it’s rather frustrating.

10 Likes

I’m currently having the same issue on my 2 favorited badges, i’m unable to unfavorite them.

Seem like it is because of badges stack, this issue happen when earning an already earned and favorited badge.

578899f2be62bb8bd3db0b1398d833e8

10 Likes

Still having this issue.

5 Likes

Issue is still occurring

5 Likes

It seems to work fine on my end, Maybe check your browser information, maybe that should fix it


[wanted to post it on an alt but realised my main actually has favorited badges and not my alt]

2 Likes

This only occurs when you have a stacked badge favourited. In my case, I have 2 Great Topic badges and 4 Good Topic badges, for a total of “6” badges favourited. I can’t toggle anything. Singular badges seem to be fine.

I’m failing to understand why someone would want the need to favorite a badge in the first place.

3 Likes

It’s just a feature on the site

1 Like


I went to favorite stacked badges and still cannot reproduce this bug

If someone can provide 100% repro steps to this problem that would help us.

Does this occur on other Discourse websites like meta.discourse.org ?

I cannot reproduce this on Discourse Meta, no. I just logged in, went to the badges section, and attempted to favorite 2 badges. It worked perfectly for me.

This was flagged on Meta in 2021, but I don’t think it’s quite the same issue. The error message is the same generic “FAILED” but the reproduction steps aren’t the same.

However, I do think we’re missing a crucial thing here. Looking at all the people reporting the issues, they all have favorited stacked badges. Yet, @vscplays was unable to favorite and unfavorite them just fine.

I was able to select my favorite badges a long time ago when I had individual ones, but now that I have stacked copies I can no longer unselect them, so maybe it’s due to getting more copies after you’ve favorited them, since each badge is unique no matter how many duplicates you get? That’s my current reasoning, but of course without being able to poke at the actual Discourse installation I can’t prove that.

Edit:

Based on the generator tag, the version of Discourse on the devforum is v3.0.3, which means the underlying code that handles badge favoriting is this:

There are two potential fail conditions here.

return render json: failed_json, status: 403 unless can_favorite_badge?(user_badge)

can_favorite_badge? for brevity returns a failure if the badge doesn’t belong to the current user or if the badge ID is 1-4, which are badges relating to trust levels. I highly doubt it’s this.

Next failure condition is

if !user_badge.is_favorite &&
     user_badges.select(:badge_id).distinct.where(is_favorite: true).count >=
       SiteSetting.max_favorite_badges
  return render json: failed_json, status: 400
end

We can already eliminate this since the badge is already favorited, but even then this shouldn’t be the issue because the badge_id from my understanding isn’t unique (hence the distinct call), it’s the same between every instance of a stacked badge.

These are the only two error cases that return that specific FAILED message in this route. As far as I’m aware, if the controller itself was failing, it should’ve returned an internal server error, not a bad request, so I don’t really understand what else could be failing here.

Also, in my search through the codebase and some googling, I found what appears to be the exact issue on Meta, but it wasn’t ever resolved:

In their screenshot you can clearly see the badges are stacked and they’re already favorited, so I do think this is the issue.

6 Likes
  1. Earn a badge.
  2. Favorite the badge.
  3. Earn the same badge again.
  4. Unfavorite it (not working - “FAILLED” error message)
1 Like

Thanks for going through this effort! Yeah this is a tough one, since it occurs in Discourse code base which we don’t directly control. In the past when we had to work with Discourse for code fixes it was a significant burden and roundtrip time to get things merged and waiting for a new version to be pushed.

I definitely recommend bumping the meta thread and/or if you know the code fix to make, you could pre-empt it and let the Discourse team know, maybe they can pull in the change so we can consume it eventually. Unfortunately since it lives in Discourse code and given the other 100 things we’re always working on at the same time, I can’t really promise we would have time for this any time soon.

2 Likes

As a former Discourse sysadmin, yeah. This sucks massively. It’s good forum software but it’s a pain to get anything fixed and pushed in a reasonable timeframe. Ended up moving to Flarum because of it, although not sure of the development status on that one.

I have bumped meta already so it’s just playing the waiting game. Honestly it could also be related to the fact we’re on a version of Discourse that’s about a year or two old now so they might not even be willing to support it beyond “upgrade to latest”.

I like Ruby but not nearly that much, plus the issues mentioned above mean it might take ages before such a fix gets deployed. Would love to do it for anything else given the opportunity though.

And yeah that’s totally understandable. I’m sure the forum software having a bug like “can’t unfavorite a badge” is extremely minor in comparison. Take your time!

1 Like