Welcome to Codidact Meta!
Codidact Meta is the meta-discussion site for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.
Sorting by score after excluding a tag gave me a 500 error
I added a filter to exclude [tag:status-launched] and then sorted by score. I was redirected to https://meta.codidact.com/categories/10?predefined_filter=&min_score=&max_score=&min_answers=&max_answers=&status=any&exclude_tags=["984"]&sort=score
Here is the error code produced: 1a5cd4d1-b811-4984-a9e1-0be1fa08ade6
What did I break?
1 answer
First, to quote from the 500 page:
It's not your fault.
Thanks for raising this.
Instant workaround
For your particular combination of filters and sorting criterion, here is a corrected link that you can use until the bug is fixed:
Once you are on that page, you can bookmark it if you wish, to avoid the need to keep coming back to this answer. Bear in mind that the bookmark (and this link) may stop working once the bug is fixed.
What works and what doesn't
Sorting by any criterion works fine with any filters apart from the tags filters. You don't need to avoid filters in general.
If any tags are included and/or excluded in the filter, then sorting by any criterion will fail with the 500 message mentioned. This affects all categories for all communities.
Awkward workaround
For combinations of filters and sorting criteria other than the one in the "Instant workaround" section above, you can construct your own workaround link if you wish (only necessary if your filters include tags):
- Apply all of the filters you want
- Instead of pressing a sort button, paste the appropriate sort string onto the end of the URL in the address bar on that filtered page
- To sort by "Age", use
&sort=age
- To sort by "Score", use
&sort=score
- To sort by "Random", use
&sort=lottery
- To sort by "Age", use
- Press Enter on your keyboard and the page will display correctly filtered and sorted
- At this point you can bookmark the page or copy the URL from the address bar to share it as a link
Note that this is likely to stop working once the bug is fixed, so if you bookmark or share a particular sorted filtered list using this workaround, you may need to update it later.
Root cause (you don't need to read this section unless you're fixing the bug or curious)
There is a bug in the URL, which prevents the server from understanding it.
The behaviour for included and excluded tags is similar, as is the behaviour for 1 or multiple tags, so for brevity only multiple excluded tags are covered here.
Multiple tags excluded
The URL before sorting:
https://meta.codidact.com/categories/10?predefined_filter=&min_score=&max_score=&min_answers=&max_answers=&status=any&exclude_tags[]=984&exclude_tags[]=985
This ends in &exclude_tags[]=984&exclude_tags[]=985
.
The (broken) URL after sorting:
https://meta.codidact.com/categories/10?predefined_filter=&min_score=&max_score=&min_answers=&max_answers=&status=any&exclude_tags=[%22984%22,%20%22985%22]&sort=score
This ends in &exclude_tags=["984", "985"]&sort=score
.
The workaround URL:
https://meta.codidact.com/categories/10?predefined_filter=&min_score=&max_score=&min_answers=&max_answers=&status=any&exclude_tags[]=984&exclude_tags[]=985&sort=score
This ends in &exclude_tags[]=984&exclude_tags[]=985&sort=score
.
Potential fixes
The broken version uses a single parameter &exclude_tags
followed by a comma separated list of tag ids in double quotes, whereas the working version uses a separate &exclude_tags
parameter per excluded tag. This suggests one of the following approaches to fixing the bug:
- Make clicking on a sorting button link to a URL using a separate
&exclude_tags
parameter per excluded tag (matching the workaround provided above) - Use a single
&exclude_tags
parameter everywhere (before and after sorting) and fix the code to be able to understand this
The first approach will probably be quicker to implement, but the second approach will avoid excessively long URLs, and I suspect was probably the original intention.
1 comment thread