Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Write to log when error is shown in PR detail view #1199
Conversation
Previously null was being returned and information about what went wrong was lost.
| @@ -350,7 +345,7 @@ static bool HasPreamble(string file, Encoding encoding) | |||
| { | |||
| foreach (var b in encoding.GetPreamble()) | |||
| { | |||
| if(b != stream.ReadByte()) | |||
| if (b != stream.ReadByte()) | |||
| @@ -351,6 +354,7 @@ public override void Initialize(ViewWithData data) | |||
| .ObserveOn(RxApp.MainThreadScheduler) | |||
| .Catch<IPullRequestModel, Exception>(ex => | |||
| { | |||
| log.Error("Error observing GetPullRequest", ex); | |||
jcansdale
Aug 25, 2017
Author
Collaborator
Add logs when exception is displayed on UI.
Add logs when exception is displayed on UI.
|
|
||
| if (sha == null) | ||
| { | ||
| throw new NotFoundException($"Couldn't find merge base between {pullRequest.Base.Sha} and {pullRequest.Head.Sha}."); |
jcansdale
Aug 25, 2017
Author
Collaborator
This exception is now thrown from GetPullRequestMergeBase (with more info about what went wrong).
This exception is now thrown from GetPullRequestMergeBase (with more info about what went wrong).
jcansdale
Aug 25, 2017
Author
Collaborator
What happens if an exception is thrown from a Observable.Defer(async () =>?
What happens if an exception is thrown from a Observable.Defer(async () =>?
| { | ||
| await gitClient.GetPullRequestMergeBase(repo, baseUri, headUri, baseSha, headSha, baseRef, headRef); | ||
| } | ||
| catch (NotFoundException) { } |
shana
Aug 25, 2017
Collaborator
Ignoring an exception in a test is weird. Is it supposed to throw or not?
Ignoring an exception in a test is weird. Is it supposed to throw or not?
jcansdale
Aug 25, 2017
Author
Collaborator
It's certainly a bit unusual. The method it's calling would previously return a null when a comment couldn't be fetched/found. It now throws an exception.
The test is to check whether or not Fetch was called. It doesn't care about the exception or exception message. There is another test for that.
It's certainly a bit unusual. The method it's calling would previously return a null when a comment couldn't be fetched/found. It now throws an exception.
The test is to check whether or not Fetch was called. It doesn't care about the exception or exception message. There is another test for that.
shana
Aug 25, 2017
Collaborator
Ah ok, in that case we should probably document that with a comment, so we know in a year from now what the assumption here is.
Ah ok, in that case we should probably document that with a comment, so we know in a year from now what the assumption here is.
| @@ -394,7 +394,7 @@ public Task<bool> IsModified(IRepository repository, string path, byte[] content | |||
| baseCommit = repo.Lookup<Commit>(baseSha); | |||
| if (baseCommit == null) | |||
| { | |||
| return null; | |||
| throw new NotFoundException($"Couldn't find {baseSha} after fetching from {baseCloneUrl}:{baseRef}."); | |||
shana
Aug 25, 2017
Collaborator
So I understand why you'd want the details of the shas in the log, but this error message is incredibly cryptic, there is no way anyone is going to know what is going on with an error like this, and this is going to be displayed directly to a user where it's going to be completely useless.
We should have a message for the user, and another with more details for the log. If the log is only showing the message and stacktrace, we can set InnerException with the log details and have the outer exception be for the user.
So I understand why you'd want the details of the shas in the log, but this error message is incredibly cryptic, there is no way anyone is going to know what is going on with an error like this, and this is going to be displayed directly to a user where it's going to be completely useless.
We should have a message for the user, and another with more details for the log. If the log is only showing the message and stacktrace, we can set InnerException with the log details and have the outer exception be for the user.
shana
Aug 25, 2017
Collaborator
Also, are all the callers of this method expecting an exception to be thrown and handling it properly?
Also, are all the callers of this method expecting an exception to be thrown and handling it properly?
jcansdale
Aug 25, 2017
Author
Collaborator
Callers of this method previously turned the null into an exception themselves. I've also tested it by making this method always throw to check that nothing bad happens. The exception message is displayed as expected.
Callers of this method previously turned the null into an exception themselves. I've also tested it by making this method always throw to check that nothing bad happens. The exception message is displayed as expected.
jcansdale
Aug 25, 2017
Author
Collaborator
I wonder what the user facing message should say? I suspect that for some reason, fetch doesn't always work or there is some race condition. I guess we could suggest thry try again or maybe refresh. I'll investagate...
I wonder what the user facing message should say? I suspect that for some reason, fetch doesn't always work or there is some race condition. I guess we could suggest thry try again or maybe refresh. I'll investagate...
shana
Aug 25, 2017
Collaborator
Yeah, an indication of what the user action should be in the case of this error would be great!
Yeah, an indication of what the user action should be in the case of this error would be great!
shana
Aug 25, 2017
Collaborator
So "merge base" may be meaningless to a user, and try again might not be helpful either if the action that the user performed to get here isn't available from this screen.
What is the action that failed here? Opening a file? Showing the PR details? The first part of the message should say what was the action that failed.
What is try again? Refresh? Click on the PR button in the toolbar and then clicking on the PR again? The second part should say what the user can do on this screen to attempt to make it work.
Assuming it was the PR that failed to load, then we should probably say something like
The Pull Request failed to load. Please check your network connection and click refresh to try again.
Adjust accordingly for the failed action.
So "merge base" may be meaningless to a user, and try again might not be helpful either if the action that the user performed to get here isn't available from this screen.
What is the action that failed here? Opening a file? Showing the PR details? The first part of the message should say what was the action that failed.
What is try again? Refresh? Click on the PR button in the toolbar and then clicking on the PR again? The second part should say what the user can do on this screen to attempt to make it work.
Assuming it was the PR that failed to load, then we should probably say something like
The Pull Request failed to load. Please check your network connection and click refresh to try again.
Adjust accordingly for the failed action.
jcansdale
Aug 25, 2017
Author
Collaborator
Okay, I've chained it to variants of your suggestion above.
My concern was that we hide the real issue behind a workaround. I'm still keen to get to the bottom of what's going wrong. My hunch is that it's a race condition in gitlib2sharp. I'll see if I can reproduce the issue with some standalone code... 😄
Okay, I've chained it to variants of your suggestion above.
My concern was that we hide the real issue behind a workaround. I'm still keen to get to the bottom of what's going wrong. My hunch is that it's a race condition in gitlib2sharp. I'll see if I can reproduce the issue with some standalone code...
shana
Aug 25, 2017
Collaborator
Yes, we don't want to hide the issue in a workaround. If you're concerned about people not reporting it, you can add "If this issue persists, please let us know at support@github.com"
Yes, we don't want to hide the issue in a workaround. If you're concerned about people not reporting it, you can add "If this issue persists, please let us know at support@github.com"
jcansdale
Aug 25, 2017
Author
Collaborator
Done. Also confirmed that nested exceptions appear in logs.
Done. Also confirmed that nested exceptions appear in logs.
This method now throws `NotFoundException` rather than returning null.
|
|


These commits were originally intended to help track down the 'Couldn't find merge base' issue #1190. This issue hasn't been resolved yet, but I think having the extra logging and exception detail will be useful stand alone.
When the following error is displayed, the exception detail will also be written to the log.
