Find a bug and fix multiple bugs
Earlier in the year, whilst working on Omniworlds RPG, I came across an issue on the Discord Bot where it was constantly throwing an error of
invalid item < at position 0 when trying to access a list of NPCs. On top of this, when calling the same endpoint via Insomniac, I also found that the API was limiting the response to 10 entries for some unknown reason.
After an initial search and attempt at rectifying the error on NodeJS, I decided to give up on that side and move on to the response issue and after a decent search, it was mentioned by a viewer that the potential NodeJS error was to do with
json_encode() failing silently in PHP. I applied some error handling on that function and amazingly it was throwing the following error:
Malformed UTF-8 characters, possibly incorrectly encoded!
I went back further through the code to trace back the errors cause and added
;charset=utf8” to the PDO connection string for the database calls and amazingly both issues were solved! The API was no longer limiting responses to 10 entries and the NodeJS invalid JSON error was suddenly gone. It goes to show that sometimes, there can be a silent bug in your code that you are unaware of that has a knock on effect with other parts of your code!