mptwaktusolat / app_waktu_solat_malaysia

Prayer times app for Malaysia. Accurate data from JAKIM. Install the app on your phones now.
https://play.google.com/store/apps/details?id=live.iqfareez.waktusolatmalaysia
GNU General Public License v3.0
46 stars 22 forks source link

[Incident] Tahun baru 2024 Incident Report #216

Open iqfareez opened 10 months ago

iqfareez commented 10 months ago

Overview

At approximately 1 AM, 1 Jan 2024 (Malaysia Time GMT+8), I noticed that the homescreen widget not showing the information properly.

image

Some person also reporting the same thing on Facebook

It just show the template data, which indicates that it has the prayer time data. But somehow cannot display them.

Chronology

I started investigating the issue related to the homescreen widget. Upon reading the logcat, I understand that the app is loading the data for December 2023.

After spending few hours looking at widget, I moved my focus to the api: https:://api.waktusolat.app. I immediately noticed that the requested year is not the same as response year.

Below is reenactment of the issue:

image

At this time, I was super sleepy eepy. I quickly looked at the source code for the endpoint and noticed that the response year the API is returning is not from the query. It is from the Date function apparently. So quick fix before going to bed, I just pass the query year to the response year. Like bypassing the Date function. Not thinking any issues that could happened.

After waking up for Subuh. my email flooded with reports for error:

type string is not type int

image

image

image

image

image

image

The error may look similar to https://github.com/mptwaktusolat/app_waktu_solat_malaysia/issues/23#issuecomment-723678770 and some others.

Now, checking the API response, I found out that the year property that we quick fix before, returns a string instead of a integer. Duh..

image

I'm out of home when checking and attempt to solve this isssue. I did not bring laptop or tablet, so I have to resort to my phone. The struggle is real. As a quick fix, I just changed the type from string to number by using Number function. Problem solved.

Understanding the issue

Now we understand the root issue for this messes is coming from bad API response data. To recall, here is the problem started:

I immediately noticed that the requested year is not the same as response year.

Below is reenactment of the issue:

image

What caused this behavior at the first place? Well, is the Date function!

We (Malaysia) are at GMT +8 zone, while the server that this API is served is somewhere not in Malaysia. So, the API returns the year that country. So, when the system wanted to determine its current year, it returns the different year from Malaysia.

Mitigation Strategy

Below is the example: code-sample

Conclusion

No longer have the aforementioned error.

The widget also working now

image

I'm lucky I can remediate this issue immediately because it only happened on the server side. If it were happened on client side, I will need everyone to update the app once it's published.