KH

A user helped me solve a long-standing bug on random anime

About a 5 minute read

Written by Kyle Hawk on May 6, 2026

#coding#debugging#random-anime

I frequently get emails from users of random anime. Sometimes it’s just noise or spam, but other times it’s people genuinely reaching out for one reason or another. I got an email a few days ago from a user describing a bug on the site.

My first thought was, is it really a bug or just the site behaving in a way they don’t expect? Lucky for me, they provided their email so I was able to respond with some follow-up questions. To their credit, they came back with the steps they were taking and what they were seeing.

The bug they described was definitely odd; the site was adding additional excluded tags when generating a custom list. I went through the steps to re-create, or at least I thought I did, and was unable to do so. My wife (shout out wifey!) and I sat at my computer, re-reading the message, both going through the steps and trying to figure out what gives. We did it in multiple browsers and mobile devices; couldn’t re-create. Weird.

That’s when I decided to reach out to the user again. Earlier today, I got the response that every person trying to debug a situation dreams of. They not only sent the list they created, but a screen recording of the bug in question! A quick view of the video not only confirmed that this was definitely a bug, it highlighted what I was doing wrong in the re-creation steps I was taking.

When I was trying to re-create, I was only including genres with the tags, not excluding them. The bug was exclusively when excluded tags and genres were used together. Re-created it on my computer and on my local environment. Alright. Time to dig in.

Debuggin’ time

Initial impression, it’s a state issue on the UI. I haven’t touched the UI in a while, but I know for a fact that both of those dropdowns use the same component. Maybe there is some weird state-bleeding going on? Why with exclusions, specifically? No idea.

A quick look at the network tab shot down that idea. The POST request payload had the correct parameters. Side note, I send the name instead of the ID.. why the hell did I do that? On the response, it’s IDs. Anyway, that’s for another day.

Okay. So the UI is sending it correctly. So it’s an API issue.. but where?

The parameters get stored as a single, encoded string. Why is it encoded? Fuck if I know, I wrote the API like 5-6 years ago, which is why it’s surprising that this bug has persisted for so long. I believe it was leftover from when I used the actual ids of the anime in the list and was doing an encoding to condense the string. I don’t know. Anyway.

The encoded string was fine. Okay. How are they going in? Couple print_r later.. Whoa. Parameters come in and validate correctly, but have the additional, unwanted tag exclusions right before encoding. What the hell?

Then I see it. I was using the same variable name that I did in the validation of genres above. More specifically, it was a short-hand to push to an array, $ids[] =. Boom, there it is.

That variable wasn’t cleared out after being used in the genre validation. Yeah, yeah it should be scoped I KNOW THAT’S WHY I’M RE-WRITING THE API.

Added a line to clear out the variable after each validation. Bing bang boom, bug solved.

HUGEEEEE shoutout to haruu, you are a legend. Thank you for using the site and caring enough to bring the bug to my attention, as well as your legendary screen recording.

Thanks for reading about me being bad at coding.