slapperwan / gh4a

Github client for Android
Apache License 2.0
1.71k stars 220 forks source link

App crashes when clicking on deleted repo in news feed #1401

Open sirjofri opened 1 month ago

sirjofri commented 1 month ago

Today, my news feed showed that someone forked a repo. Since the forked repo showed up as (deleted)/reponame, I assume it was deleted in the mean time. However, clicking on that news feed entry immediately crashes the app.

Screenshot_20240927-130547

Fs00 commented 1 month ago

It looks like that the account that created the fork was deleted. Could you please share the logcat output of the crash so we can see the place in the code where the error occurs?

Fs00 commented 1 month ago

Never mind, I've managed to find an occurrence of the crash myself. The relevant logcat output is:

FATAL EXCEPTION: main
Process: com.gh4a, PID: 32073
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.meisolsson.githubsdk.model.User.login()' on a null object reference
    at com.gh4a.activities.RepositoryActivity.makeIntent(RepositoryActivity.java:56)
    at com.gh4a.activities.RepositoryActivity.makeIntent(RepositoryActivity.java:52)
    at com.gh4a.fragment.EventListFragment.onItemClick(EventListFragment.java:188)
    at com.gh4a.fragment.EventListFragment.onItemClick(EventListFragment.java:88)
    at com.gh4a.adapter.RootAdapter.onClick(RootAdapter.java:271)
    at com.gh4a.adapter.EventAdapter.onClick(EventAdapter.java:118)
    at android.view.View.performClick(View.java:7259)
    at android.view.View.performClickInternal(View.java:7236)
    at android.view.View.access$3600(View.java:801)
    at android.view.View$PerformClick.run(View.java:27892)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)

I'll try to look into it.

Fs00 commented 2 weeks ago

Small update: I've noticed that the issue is caused by a silent breaking change of the GitHub events API, which is returning less fields of the forked repository than the app expects. I've contacted GitHub support two weeks ago to report the problem, but I haven't received an answer yet. In the worst case, the app can be adapted to work with the changed API without too much effort.

Fs00 commented 2 days ago

I have some good news: GitHub has fixed the issue on their side. Unfortunately, fork events happened after the unintentional breaking change but before the fix will still contain the broken payload and can therefore crash the app. I plan to open a PR to fully address the issue on the app side.