You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide a better error message and give users the option to retry a failed clone #926
As of #924, we tell the user when a clone has failed, but the user now has to close out of the error message, go back into the clone dialog, select the same repo again, and clone. A better solution would be to provide users the option to immediately retry cloning the same repo if it fails.
I talked with @iAmWillShepherd and have looked into the error handlers and how to detect this error in order to throw a user friendly error in it's place as per the previous Issue #2838.
I ran into an issue with being able to properly detect the error. I started by debugging the error handlers to see what the error object contained as it is passed through. I started in gitAuthenticationErrorHandler() and placed a breakpoint before causing the clone failed error to be emitted. The error that was passed into the error handler did not seem to have much distinguishing information (primarily a 128 exit code and the error text itself). Here is what the function did with the error:
The clone error is passed into the gitAuthenticationErrorHandler.
The error has a result object that contains an exit code 128, a null gitError, and null gitErrorDescription. It has the error message in the stderr variable.
The handler passes the error to asErrorWithMetadata() and checks if the result is null. The result is not null and it continues.
The handler then passes the error to asGitError() and checks if the result is null. The result is not null and continues.
Then it checks if the error's result's gitError variable is null. The check is returning true and the handler returns the error immediately.
It seems strange that this information was null. The 128 exit code seems to be generic and the main identifying information is the error text itself. This seems unusual given that the other error handlers seem to expect and rely on git and dugite errors. I had intended to use this information to attempt to add a handler for this specific cloning error.
Given the details provided my initial feeling is that the app isn't parsing the output from git() to an error in the way you're expecting. I'll walk through the extra context on what happens before the error handlers fire that I believe is relevant to the root cause of your issue:
Errors are parsed when an exit code doesn't match the successExitCodes set (by default this is just a set containing 0, so any non-zero exit code should trigger error parsing).
Ensure you haven't set 128 as a successExitCodes value, otherwise git() will not bother parsing for errors. clone.ts doesn't look like it passes in a successExitCodes option, so I think this is fine.
If the function should parse for errors, it will first try and parse stderr for a matching DugiteError, and if no match is found it will fall back to reading stdout.
This is where I have questions about what you are seeing currently:
what do stderr and stdout contain?
looking at the list of regexes here, what output are you expecting to match to which error from this list?
This could be something changing between Git versions and we just need to tweak dugite to add a new mapping (or relax an existing regex). This is what I would focus on stepping through as part of seeing the clone fail.
We build up the IGitResult to return here by appending the description (if a DugiteError was found):
If we have no gitError, we likely won't have a gitErrorDescription.
Whether this function returns or errors is driven by the expectedErrors parameter passed into git() - this is a way for the caller to anticipate an error and handle it itself rather than propagate this to the error handlers.
I believe git() is throwing an error here for all clones that error, because you're seeing the error handlers fire, but that's something to be aware of if you're interested in changing the behaviour of how clone.ts works.
@shiftkey This is wonderful information! Thank you for sharing all this in such great detail. I found this very useful.
After reading this I have compared the stderr I was getting compared to the available regex patterns.
Dugite includes this pattern: "fatal: unable to access '(.+)': Failed to connect to (.+): Host is down": GitError.HostDown,
This is the stderr I was receiving: "Cloning into '/home/hellokitty/Documents/GitHub/Chixel'... fatal: unable to access 'https://github.com/Daniel-McCarthy/Chixel.git/': Could not resolve host: github.com"
It appears the regex pattern is no longer matching the error. Unless there are extra factors to consider, I think we could update the pattern in dugite to: "Cloning into '(.+)'... fatal: unable to access '(.+)': Could not resolve host: (.+)"
@Daniel-McCarthy this seems like a good contribution to dugite as a pre-requisite for this work.
These PRs where we've made changes to the error parsing should be a good guide to show what needs to change: desktop/dugite#306desktop/dugite#271
Unless there are extra factors to consider, I think we could update the pattern in dugite to: "Cloning into '(.+)'... fatal: unable to access '(.+)': Could not resolve host: (.+)"
My gut feels that this should be an additive regex that maps to the same error code, because I'm not 100% sure the old message is deprecated. Could not resolve host comes from here inside curl (which Git depends upon):
I couldn't find the same Host is down message in curl, but that might be because it receives this message from the underlying OS. Anyway, we can talk more about this in the PR.
I talked with @shiftkey to get a better idea of what the scope of this proposed functionality would be. I was hoping to work on #2838, which was marked Help Wanted but was merged into this Issue. However, it seems that this Issue still requires some more thought and is not currently marked Help Wanted. Perhaps @desktop/product would have a good idea of what this feature would entail. Any thoughts would certainly be appreciated.
Chatted with @Daniel-McCarthy about this, and added help wanted here as they've already made progress on surfacing a better error message here and getting the internals set up to try the clone again. We discussed that the popup surface would have the error message, and also a "Close" button and a "Retry Clone" button. Feel free to ask if anyone has additional questions.
@billygriffin
This appears to be what is thrown when cloning with no internet connection as of Dugite #308. I mentioned I would update this thread with the error that would now be thrown when Dugite is next bumped.
@Daniel-McCarthy Thanks! That's a bit of an odd one but I still think it provides some information that's a bit more plain language to where it's better than what's present today. 😄
changed the title [-]Give the user the option of retrying a failed clone[/-][+]Provide a better error message and give users the option to retry a failed clone[/+]on Mar 7, 2019
I have the base for a pull request ready. However, if one wishes to test the retry cloning dialog via the host is down error, then Dugite must be bumped to version 1.86.0 first.
However, in order to bump Dugite there is a pending change that needs to be made (A description for DugiteError.UnresolvedConflicts seemingly needs to be added to the getDescriptionForError function in src/lib/git/core.ts). I will capture this in a separate Issue.
Just dropping a note in here to indicate the clone is not resumable by default in Git, so this "retry" step won't reuse the previous clone attempt. I wrote up a workaround in #7440 if you work in an environment with a really flaky network.
Now, when trying to clone a repo from an external host (gitlab in this case), instead of prompting me for my gitlab credentials once authentification with github fails, I enter on the infinite retry loop.....
Activity
Daniel-McCarthy commentedon Feb 28, 2019
I talked with @iAmWillShepherd and have looked into the error handlers and how to detect this error in order to throw a user friendly error in it's place as per the previous Issue #2838.
I ran into an issue with being able to properly detect the error. I started by debugging the error handlers to see what the error object contained as it is passed through. I started in
gitAuthenticationErrorHandler()and placed a breakpoint before causing the clone failed error to be emitted. The error that was passed into the error handler did not seem to have much distinguishing information (primarily a 128 exit code and the error text itself). Here is what the function did with the error:It seems strange that this information was null. The 128 exit code seems to be generic and the main identifying information is the error text itself. This seems unusual given that the other error handlers seem to expect and rely on git and dugite errors. I had intended to use this information to attempt to add a handler for this specific cloning error.
shiftkey commentedon Mar 1, 2019
@Daniel-McCarthy
Given the details provided my initial feeling is that the app isn't parsing the output from
git()to an error in the way you're expecting. I'll walk through the extra context on what happens before the error handlers fire that I believe is relevant to the root cause of your issue:successExitCodesset (by default this is just a set containing0, so any non-zero exit code should trigger error parsing).desktop/app/src/lib/git/core.ts
Lines 129 to 131 in 40a7aba
Ensure you haven't set
128as asuccessExitCodesvalue, otherwisegit()will not bother parsing for errors.clone.tsdoesn't look like it passes in asuccessExitCodesoption, so I think this is fine.stderrfor a matchingDugiteError, and if no match is found it will fall back to readingstdout.desktop/app/src/lib/git/core.ts
Lines 132 to 137 in 40a7aba
This is where I have questions about what you are seeing currently:
stderrandstdoutcontain?This could be something changing between Git versions and we just need to tweak
dugiteto add a new mapping (or relax an existing regex). This is what I would focus on stepping through as part of seeing the clone fail.IGitResultto return here by appending the description (if aDugiteErrorwas found):desktop/app/src/lib/git/core.ts
Lines 139 to 140 in 40a7aba
If we have no
gitError, we likely won't have agitErrorDescription.expectedErrorsparameter passed intogit()- this is a way for the caller to anticipate an error and handle it itself rather than propagate this to the error handlers.desktop/app/src/lib/git/core.ts
Lines 142 to 149 in 40a7aba
You can see an example of this over in #6961 with the rebase workflow:
desktop/app/src/lib/git/rebase.ts
Lines 190 to 200 in 76d48b9
I believe
git()is throwing an error here for all clones that error, because you're seeing the error handlers fire, but that's something to be aware of if you're interested in changing the behaviour of howclone.tsworks.Daniel-McCarthy commentedon Mar 1, 2019
@shiftkey This is wonderful information! Thank you for sharing all this in such great detail. I found this very useful.
After reading this I have compared the
stderrI was getting compared to the available regex patterns.Dugite includes this pattern:
"fatal: unable to access '(.+)': Failed to connect to (.+): Host is down": GitError.HostDown,This is the
stderrI was receiving:"Cloning into '/home/hellokitty/Documents/GitHub/Chixel'... fatal: unable to access 'https://github.com/Daniel-McCarthy/Chixel.git/': Could not resolve host: github.com"It appears the regex pattern is no longer matching the error. Unless there are extra factors to consider, I think we could update the pattern in dugite to:
"Cloning into '(.+)'... fatal: unable to access '(.+)': Could not resolve host: (.+)"shiftkey commentedon Mar 1, 2019
@Daniel-McCarthy this seems like a good contribution to
dugiteas a pre-requisite for this work.These PRs where we've made changes to the error parsing should be a good guide to show what needs to change: desktop/dugite#306 desktop/dugite#271
My gut feels that this should be an additive regex that maps to the same error code, because I'm not 100% sure the old message is deprecated.
Could not resolve hostcomes from here insidecurl(which Git depends upon):https://github.com/curl/curl/blob/65eb65fde64bd5faff6d6a7740f9436336e290e0/lib/asyn-thread.c#L458-L459
I couldn't find the same
Host is downmessage incurl, but that might be because it receives this message from the underlying OS. Anyway, we can talk more about this in the PR.Daniel-McCarthy commentedon Mar 1, 2019
@shiftkey Wonderful. Thanks again for the help and fantastic information. I will look into adding this regex pattern to Dugite.
Daniel-McCarthy commentedon Mar 5, 2019
I talked with @shiftkey to get a better idea of what the scope of this proposed functionality would be. I was hoping to work on #2838, which was marked
Help Wantedbut was merged into this Issue. However, it seems that this Issue still requires some more thought and is not currently markedHelp Wanted.Perhaps @desktop/product would have a good idea of what this feature would entail. Any thoughts would certainly be appreciated.billygriffin commentedon Mar 7, 2019
Chatted with @Daniel-McCarthy about this, and added
help wantedhere as they've already made progress on surfacing a better error message here and getting the internals set up to try the clone again. We discussed that the popup surface would have the error message, and also a "Close" button and a "Retry Clone" button. Feel free to ask if anyone has additional questions.Daniel-McCarthy commentedon Mar 7, 2019
@billygriffin

This appears to be what is thrown when cloning with no internet connection as of Dugite #308. I mentioned I would update this thread with the error that would now be thrown when Dugite is next bumped.
billygriffin commentedon Mar 7, 2019
@Daniel-McCarthy Thanks! That's a bit of an odd one but I still think it provides some information that's a bit more plain language to where it's better than what's present today. 😄
[-]Give the user the option of retrying a failed clone[/-][+]Provide a better error message and give users the option to retry a failed clone[/+]Daniel-McCarthy commentedon Mar 11, 2019
I have the base for a pull request ready. However, if one wishes to test the retry cloning dialog via the host is down error, then Dugite must be bumped to version
1.86.0first.However, in order to bump Dugite there is a pending change that needs to be made (A description for
DugiteError.UnresolvedConflictsseemingly needs to be added to thegetDescriptionForErrorfunction insrc/lib/git/core.ts). I will capture this in a separate Issue.shiftkey commentedon May 6, 2019
Just dropping a note in here to indicate the clone is not resumable by default in Git, so this "retry" step won't reuse the previous clone attempt. I wrote up a workaround in #7440 if you work in an environment with a really flaky network.
manugd14 commentedon May 12, 2020
Now, when trying to clone a repo from an external host (gitlab in this case), instead of prompting me for my gitlab credentials once authentification with github fails, I enter on the infinite retry loop.....