slapperwan / gh4a

Github client for Android
Apache License 2.0
1.73k stars 221 forks source link

Improve debug facilities (was: Error when trying to close an open issue) #629

Open f1u77y opened 7 years ago

f1u77y commented 7 years ago

Steps to reproduce:

  1. Open an issue on any project you can
  2. Try to close it from the app

Expected results

The issue becomes closed

Actual results

The issue does not become closed and app shows an "Error closing issue" popup.

EDIT it's strange but that functionality works on this issue. But it still doesn't work for other repos.

maniac103 commented 7 years ago

Can you please attach the logcat output after such a failed attempt?

hjchanna commented 7 years ago

I've tested, i did not get any error. Issue was closed successfully.

sharkykh commented 7 years ago

@f1u77y You need to, or ask the repo owner to authorize the OctoDroid OAuth app in the repo settings on Github for it to work.

I'm having the same error on a repo I'm a member of, but that's not an issue because the repo owner didn't authorize the app.

Edit: Actually having a similar issue, on a repo I'm not a member of. I have a PR that I opened, and when I edit it from the app and try to save, it throws an error. Unfortunately I'm unable to get logs as I don't have Android Studio installed.

I guess it depends on whether or not the repo owner has authorized OctoDroid.

f1u77y commented 7 years ago

@sharkykh yes you're right! This is repo I'm member of.

But why can I not close my own issue there w/o authorizing as member of the organisation, just like any regular user?

maniac103 commented 7 years ago

Ask Github? ;-) But seriously, please upload the logcat snippet after this happened. The exception message will contain Github's server response.

(NB: I've thought of showing the exception message in the UI for quite a long time, but I'm not sure how exactly. Simply dropping it into the SnackBar doesn't look nice to me, and there isn't a way to show a second button :( )

maniac103 commented 7 years ago

I have a PR that I opened, and when I edit it from the app and try to save, it throws an error. Unfortunately I'm unable to get logs as I don't have Android Studio installed.

If your phone is rooted, you could use one of the logcat apps from Play Store (e.g. CatLog or MatLog).

sharkykh commented 7 years ago

@maniac103 Nope, unrooted...

You can do the same thing I did, open a PR in any repository that you're not a member of and you know didn't approve the OctoDroid app, then try to modify it in any way. ~use the test repo I just created. I revoked OctoDroid for my account for now, so you'll be able to debug it.~

Tunous commented 7 years ago

We could add an option to settings which when enabled displays dialog with error details whenever they happen.

maniac103 commented 7 years ago

More options:

Thoughts?

Tunous commented 7 years ago

These should be good.

fountaingeyser commented 7 years ago

Another option you have is using the built in app error reporting / feedback mechanism of Google by using the ACTION_APP_ERROR intent and parsing the error via the extra field EXTRA_BUG_REPORT as an ApplicationErrorReport. Your code might look something like that:

ApplicationErrorReport bug = new ApplicationErrorReport();
// TODO: create bug report
Intent intent = new Intent(Intent.ACTION_APP_ERROR);
intent.setPackage("com.google.android.gms");
intent.putExtra(Intent.EXTRA_BUG_REPORT, bug);
context.startActivity(intent);
sharkykh commented 7 years ago

Hey, FWIW, thanks to one of @maniac103's comments I was able to get the logcat of the error. It just says Issue not editable by sharkykh (403) on a pull request that I opened. I now have ADB available, so let me know if I can assist with anything in that regard.

07-15 05:12:40.408 14351 14351 D ViewRootImpl@f3b25a5[IssueEditActivity]: MSG_WINDOW_FOCUS_CHANGED 1
07-15 05:12:40.434  3780  7280 D WindowManager: finishDrawingWindow: Window{eff327bd0 u0 com.gh4a/com.gh4a.activities.IssueEditActivity} mDrawState=DRAW_PENDING
07-15 05:12:40.438 14351 14351 D ViewRootImpl@f3b25a5[IssueEditActivity]: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
07-15 05:12:40.448  3780  3877 D KnoxTimeoutHandler: notifyActivityDrawn [MsgParam] userId: 0 fullscreen is true showWhenlocked is false isMutiwindowRecord is false multiwindowstyle is 1
07-15 05:12:40.448  3780  3780 D KnoxTimeoutHandler: activityDrawn [MsgParam] userId: 0 fullscreen is true showWhenlocked is false isMutiwindowRecord is false multiwindowstyle is 1
07-15 05:12:40.450  3780  3780 I KnoxTimeoutHandler: SD activityfalse
07-15 05:12:40.450  3780  3780 I KnoxTimeoutHandler: Fullscreen and mCurrent is not KNOX user. Hence hide keyguard
07-15 05:12:40.458  3780  7261 D WindowManager: finishDrawingWindow: Window{eff327bd0 u0 com.gh4a/com.gh4a.activities.IssueEditActivity} mDrawState=HAS_DRAWN
07-15 05:12:40.479 14351 14351 D ViewRootImpl@e331bbb[IssueEditActivity]: MSG_WINDOW_FOCUS_CHANGED 0
07-15 05:12:40.517 14351 14445 W System.err: org.eclipse.egit.github.core.client.RequestException: Issue not editable by sharkykh (403)
07-15 05:12:40.518 14351 14445 W System.err:    at org.eclipse.egit.github.core.client.GitHubClient.createException(GitHubClient.java:599)
07-15 05:12:40.518 14351 14445 W System.err:    at org.eclipse.egit.github.core.client.GitHubClient.sendJson(GitHubClient.java:690)
07-15 05:12:40.518 14351 14445 W System.err:    at org.eclipse.egit.github.core.client.GitHubClient.post(GitHubClient.java:844)
07-15 05:12:40.518 14351 14445 W System.err:    at org.eclipse.egit.github.core.service.IssueService.editIssue(IssueService.java:742)
07-15 05:12:40.518 14351 14445 W System.err:    at org.eclipse.egit.github.core.service.IssueService.editIssue(IssueService.java:703)
07-15 05:12:40.518 14351 14445 W System.err:    at com.gh4a.activities.IssueEditActivity$SaveIssueTask.run(IssueEditActivity.java:551)
07-15 05:12:40.518 14351 14445 W System.err:    at com.gh4a.activities.IssueEditActivity$SaveIssueTask.run(IssueEditActivity.java:525)
07-15 05:12:40.518 14351 14445 W System.err:    at com.gh4a.BackgroundTask.doInBackground(BackgroundTask.java:26)
07-15 05:12:40.518 14351 14445 W System.err:    at com.gh4a.BackgroundTask.doInBackground(BackgroundTask.java:7)
07-15 05:12:40.518 14351 14445 W System.err:    at android.os.AsyncTask$2.call(AsyncTask.java:304)
07-15 05:12:40.519 14351 14445 W System.err:    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
07-15 05:12:40.519 14351 14445 W System.err:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
07-15 05:12:40.519 14351 14445 W System.err:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
07-15 05:12:40.519 14351 14445 W System.err:    at java.lang.Thread.run(Thread.java:762)
07-15 05:12:40.550  4841  4841 D io_stats: !@   8,0 r 65473 4899500 w 18084 658196 d 1578 472244 f 6539 6536 iot 45600 42760 th 467576 0 0 pt 0 inp 0 0 457.149
07-15 05:12:40.554 14351 14351 D ViewRootImpl@f3b25a5[IssueEditActivity]: dispatchDetachedFromWindow
07-15 05:12:40.557  3780  3853 D WindowManager: set systemUiVisibility of statusbar : vis= 0x708
07-15 05:12:40.577  3780  5073 D InputDispatcher: Focus left window: 14351
07-15 05:12:40.577  3780  5073 D InputDispatcher: Focus entered window: 14351
07-15 05:12:40.577  3780  5073 D InputTransport: Input channel destroyed: fd=512
07-15 05:12:40.578 14351 14351 D InputTransport: Input channel destroyed: fd=72
07-15 05:12:40.585  3780  7259 D WindowManager: adjustSystemUiVisibilityLw : vis= 0x708
07-15 05:12:40.604 14351 14351 D ViewRootImpl@e331bbb[IssueEditActivity]: MSG_WINDOW_FOCUS_CHANGED 1
07-15 05:12:40.607  3780  5074 D InputMethodManagerService: windowGainedFocus mCurrentFocusedUserId - 0 and mSecureKeypadEnabled-false
07-15 05:12:40.608 14351 14351 E ViewRootImpl: sendUserActionEvent() mView == null
07-15 05:12:40.746  3780  3877 I WindowManager: Destroying surface Surface(name=com.gh4a/com.gh4a.activities.IssueEditActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2838 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:1069 com.android.server.wm.WindowState.destroyOrSaveSurface:2534 com.android.server.wm.AppWindowToken.destroySurfaces:412 com.android.server.wm.AppWindowToken.destroySurfaces:376 com.android.server.wm.WindowStateAnimator.finishExit:654 com.android.server.wm.WindowStateAnimator.stepAnimationLocked:564 com.android.server.wm.WindowAnimator.updateWindowsLocked:439 
07-15 05:12:40.746  3124  3947 I SurfaceFlinger: id=74 Removed JssueEditAc (5/6)
07-15 05:12:40.757  3124  5624 I SurfaceFlinger: id=74 Removed JssueEditAc (-2/6)
Bluscream commented 7 years ago

403 is a permission related error :/

Bluscream commented 7 years ago

Btw in such cases i'd rather have a "stacktrace popup" rather than a "some generic error has occured popup"

We shouldn't forget that github is for devs and therefor most of octodroids users should be able to read that

maniac103 commented 7 years ago

I think it's a misconception to think most Github users are familiar with Java or Github's API ;-)

maniac103 commented 7 years ago

Having said that we could probably show the exception message though; maybe in small font.

Bluscream commented 7 years ago

Atleast the main line (Exception: Error Message)

maniac103 commented 7 years ago

I would do this only for request exceptions and display it among those lines: Github told us: Issue not editable by sharkykh

antenore commented 6 years ago

I've the same issue, but I cannot find where to set the permissions, can you please be so kind to point it out? Thanks! Edit: typo

antenore commented 6 years ago

I've found myself, sorry.

smichel17 commented 6 years ago

I have had this issue in the past when I had not authorized octodroid with an organization I am part of. I don't remember exactly where I fixed it, but it was somewhere in my github settings.

Edit: ha, immaculate timing

maniac103 commented 6 years ago

For the record: https://help.github.com/articles/about-oauth-app-access-restrictions/ @slapperwan This seems to be a common complaint in the Play Store reviews lately, we should probably add something about it to the Play Store description.

antenore commented 6 years ago

@maniac103 @slapperwan I don't think adding it in the playstore would be helpful because all the users updating the applications won't go in the Play Store to see what's going on. I'd personally prefer a more descriptive error (OAuth error for instance) and in the options menu a link to the OAth Github documentation with the right link text and alt attribute.

Just my 2 cents

maniac103 commented 6 years ago

The problem is that we don't get an OAuth error. We just get HTTP error 403 (unauthorized) without any indication what exactly the problem is. See @sharkykh's stack trace above. (In other cases some information simply is excluded from the server response if Octodroid isn't authorized from the org, which makes the problem totally unrecognizable)

antenore commented 6 years ago

My bad, you already have wrote this. On the other side what are the probabilities to get a 403 error only during the merge? It's quite dirty as workaround, but if you test a second URL and don't get a 403 it should be an oauth error.

maniac103 commented 6 years ago

'Test a second URL'? What do you mean? But I'm not really interested in ugly hacks anyway. We'd need a way to reliably detect the org not having authorized Octodroid without doing an action.

smichel17 commented 6 years ago

Why not: IF we get a 403 AND it is for an organization's repo, THEN inform the user that not authorizing oauth with the org is a common cause