Skip to content

Provide a better error message and give users the option to retry a failed clone #926

Closed

Description

@joshaber

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.

Activity

  1. Daniel-McCarthy commented on Feb 28, 2019

    @Daniel-McCarthy
    Member

    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.

  2. shiftkey commented on Mar 1, 2019

    @shiftkey
    Member

    @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:

    1. 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).

    const acceptableExitCode = opts.successExitCodes
    ? opts.successExitCodes.has(exitCode)
    : false

    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.

    1. 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.

    if (!acceptableExitCode) {
    gitError = GitProcess.parseError(result.stderr)
    if (!gitError) {
    gitError = GitProcess.parseError(result.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.

    1. We build up the IGitResult to return here by appending the description (if a DugiteError was found):

    const gitErrorDescription = gitError ? getDescriptionForError(gitError) : null
    const gitResult = { ...result, gitError, gitErrorDescription }

    If we have no gitError, we likely won't have a gitErrorDescription.

    1. 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.

    let acceptableError = true
    if (gitError && opts.expectedErrors) {
    acceptableError = opts.expectedErrors.has(gitError)
    }
    if ((gitError && acceptableError) || acceptableExitCode) {
    return gitResult
    }

    You can see an example of this over in #6961 with the rebase workflow:

    const result = await git(
    ['rebase', '--skip'],
    repository.path,
    'continueRebaseSkipCurrentCommit',
    {
    expectedErrors: new Set([
    GitError.RebaseConflicts,
    GitError.UnresolvedConflicts,
    ]),
    }
    )

    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.

  3. Daniel-McCarthy commented on Mar 1, 2019

    @Daniel-McCarthy
    Member

    @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: (.+)"

  4. shiftkey commented on Mar 1, 2019

    @shiftkey
    Member

    @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#306 desktop/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):

    https://github.com/curl/curl/blob/65eb65fde64bd5faff6d6a7740f9436336e290e0/lib/asyn-thread.c#L458-L459

    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.

  5. Daniel-McCarthy commented on Mar 1, 2019

    @Daniel-McCarthy
    Member

    @shiftkey Wonderful. Thanks again for the help and fantastic information. I will look into adding this regex pattern to Dugite.

  6. Daniel-McCarthy commented on Mar 5, 2019

    @Daniel-McCarthy
    Member

    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.

  7. added
    help wanted
    on Mar 7, 2019
  8. billygriffin commented on Mar 7, 2019

    @billygriffin
    Contributor

    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.

  9. Daniel-McCarthy commented on Mar 7, 2019

    @Daniel-McCarthy
    Member

    @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.
    image

  10. billygriffin commented on Mar 7, 2019

    @billygriffin
    Contributor

    @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. 😄

  11. 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
  12. deleted a comment from joshaber on Mar 7, 2019
  13. Daniel-McCarthy commented on Mar 11, 2019

    @Daniel-McCarthy
    Member

    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.

  14. shiftkey commented on May 6, 2019

    @shiftkey
    Member

    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.

  15. manugd14 commented on May 12, 2020

    @manugd14

    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.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions