Skip to content

Friendlier recovery when issue/pr create fails #906

Closed

Description

@coot

Describe the bug

Create an issue but add non-existing label with -l option. The issue will
not be submitted and the issue text will be lost.

Steps to reproduce the behavior

  1. `gh -l non-existing-label -t "Test issue"
  2. The issue is not submitted and the issue text is deleted from the hard drive.

Expected vs actual behavior

Do not delete the issue if it is not submitted!

Logs

Activity

  1. added
    bug
    on May 12, 2020
  2. vilmibm commented on May 12, 2020

    @vilmibm
    Contributor

    Unfortunately we don't at any point save issue text to the hard drive -- it's just held in RAM until the operation is submitted to the API. this is true of any data we take in; it can be lost if the operation fails.

    I think it would be nice for us to address this in a general way whenever we take data in via an editor. The paths I can think off of the top of my head:

    • suggest users use an autosave feature on their editor. I don't love this approach because editors vary in how they do autosave and it can lead to a lot of clutter or confusion.
    • print out what we're going to submit so it can be copy/pasted in case of error. I'm sort of into this but I think we found with certain issue/pr submissions that it can interrupt the flow when there is a lot of text.
    • output a "dump" in case of error, kind of like a core dump when certain programs halt. I'd imagine this as a toggle-able feature. But a flow like:
    $ gh pr create
    $ # ...do input steps
    X Failed to submit pull request: GH is temporarily down.
    ! Your submission was preserved in .gh-1589296025
    

    @ampinsk what do you think of this kind of experience? is it worth pursuing?

  3. ampinsk commented on May 12, 2020

    @ampinsk

    I like the idea of a “dump” if the operation fails! I like the sketch you provided, I think it’s worth pursuing.

  4. mislav commented on May 13, 2020

    @mislav
    Contributor

    To me, the best user experience would be if the person can just resume where they left off without any special intervention (i.e. without them having to manually inspect generated files such as a crash dump). So here is what I'm thinking: whenever someone authors a PR or issue, we save their title & body in a file scoped to that repository. If the create operation succeeded, we delete the file. Otherwise, the save file stays on disk and is used to pre-fill the next issue/pr create invocation, which is most likely a retry after a server or validation failure.

    Additionally, for the case of issue/pr create with invalid flag input (non existing labels, for example), one approach we can do is validate the inputs before we let them author the title or body. That way they get an error early and don't lose any work. The tradeoff would be that they would always get a slight delay before the title prompt appears, since their flags need to be validated on the server.

    Related: #678 #826

  5. vilmibm commented on May 13, 2020

    @vilmibm
    Contributor

    To me, the best user experience would be if the person can just resume where they left off without any special intervention (i.e. without them having to manually inspect generated files such as a crash dump).

    My initial reaction to this is that it's too implicit. A user might wander off and N days come back and use the tool to create an issue/pr only to be confused why this particular data is being pre-filled. I think I would be in favor of this approach, though, if it did something like vim's swap file detection:

    $ gh pr create
    ! It looks like this failed the last time you ran it. Would you like to pick up where you left off? [Y/n] 
    

    Additionally, for the case of issue/pr create with invalid flag input (non existing labels, for example), one approach we can do is validate the inputs before we let them author the title or body.

    I'm in favor of this sort of thing assuming we can keep the latency tolerably low but given that we'll always need to be ready for github.com potentially being down it seems like less of a priority than the ability to pick up where you left off.

  6. changed the title [-]Wrong label, deleted issue[/-] [+]Friendlier recovery when issue/pr create fails[/+] on May 13, 2020
  7. added
    enhancement
    and removed
    bug
    on May 13, 2020
  8. mislav commented on May 14, 2020

    @mislav
    Contributor

    A user might wander off and N days come back and use the tool to create an issue/pr only to be confused why this particular data is being pre-filled.

    Agreed, we need to think this through. Hub implements this, but users have been filing issues about false-positives, meaning hub trying to helpfully restore their "lost" work, but the user has switched context in the meantime (e.g. switched to another branch).

    but given that we'll always need to be ready for github.com potentially being down it seems like less of a priority than the ability to pick up where you left off.

    100% agree. The feature to avoid people losing text is in my mind of larger importance than the order of how we validate inputs.

  9. DJBlueSlime commented on May 21, 2020

    @DJBlueSlime

    Can I suggest something? (Correct me if I'm wrong in something)

    Maybe we can assign the pr or issue a totally random number (Only locally), then if the operation fails we save a file in path/to/repo/.dump/ with name <pr | issue>-<random-number>.yml, and then when the user creates a pr/issue we ask of using the MOST RECENT, and that way the user does'nt only uses the most recent but if the user has more dump files he can use that other one, like:

    $ gh pr create
    $ inputs
    Oops, Error
    ! The pr was saved with title and body in pr-236174890.yml with dump-id 236174890.
    $ tree
    .
    |
    |— .dump
            |
            |— pr236174890.yml
    |
    |— <Other Files>
    

    Yes I know, a very bad recreation of tree command,
    But the point is that, so when the user runs the command again:

    $ gh pr create
    ! Last time you ran this command It failed and created a dump file, do you want to use It?
    Use the dump file? (y/N) No
    Okay!
    
    (Continues with normal pr create procedure)
    

    If the user agreeds It takes body and title from dump file and prompts for metadata,
    If the user haves more than 1 dump file:

    $ gh pr create
    ! Last time you ran this command It failed and created a dump file, and It looks that there are more than one dump file?
    Use a dump file? (y/N) Yes
    Insert a Dump-ID (DUID): <dump-file-id> (<-- Note: Maybe this can be improved for it to show a list of dump files)
    
    (The CLI recopiles title and body from dump file and prompts for metadata)
    

    All of this applies for issue create procedure.

    When the dump file is used and the procedure fails again, the dump file is conserved, if the procedure succeds, the dump file is deleted.

    @mislav @vilmibm @coot What do you think?

  10. mislav commented on May 22, 2020

    @mislav
    Contributor

    @Josh012422 I like this general idea, and I would say that we don't even have to make it as involved, e.g. I don't think we really need to make support for multiple dump files since the original goal is to just help people recover their authored text from the most recent crash. It could be as simple as:

    $ git pr create
    notice: unsaved title and body detected
    ? Do you want to recover title and body text that you previously entered? (Y/n)
    
  11. TheCeloReis commented on May 28, 2020

    @TheCeloReis

    Meta data is also important to recover, not just the body and title.

  12. DJBlueSlime commented on May 31, 2020

    @DJBlueSlime

    Thanks @mislav about the comment, and sorry for the late response, some things happened, this is what I want to say:

    As I thinked of it, I realized that multiple dump files is something more useless than useful, because, the user only wants to use the last dump file, more than one dump file will occupy more space on disk and many of them will be useless

    Oh, mislav, I have a question: Why the CLI doesn't use viper
    And @MarcelReis, yeah metadata should also be added to dump file.

  13. mislav commented on Jun 2, 2020

    @mislav
    Contributor

    I have a question: Why the CLI doesn't use viper

    We briefly reviewed Viper, but from its project description it sounds like most of the functionality it offers is what we absolutely don't need. It sounds like Viper was primarily designed for services that are deployed to a server.

  14. DJBlueSlime commented on Jun 2, 2020

    @DJBlueSlime

    It sounds like Viper was primarily designed for services that are deployed to a server.

    Well, if you say so... I am currently developing a CLI (Gocharm if you want to look it) that has multiple kinda utilities commands (like a timer, cronometer, etc) and I use viper for config proccessing, I do not know for what was Viper really designed for.

    But ok, we are not here to talk about viper and its uses... so about the general issue, @mislav if you give me your permission, I will start working on this issue though a PR.

    P.D: I really like the CLI, I used some code from the GH CLI to use It on my on CLI, Kudos for the great work.

  15. phil-blain commented on Aug 2, 2020

    @phil-blain

    I’d just like to add my voice here, I just spent 20+ minutes writing a detailed PR description only to loose it when I submitted because I had forgotten to force push my (rebased since last pushed) branch, just as described in #1455.
    Having ‘gh’ do a backup of any textual input would be very helpful.

    (As an aside, in this situation, or even if the push would be fast-forwad, the cli could simply warn you that your branch has unpushed commits instead of pushing them for you, but I understand that this might be a design decision. I would personally prefer that the cli would ask for confirmation before running any Git command, but I can understand that it’s not the case for everyone...)

  16. mislav commented on Aug 27, 2020

    @mislav
    Contributor

    @phil-blain We hear you. I'm sorry your work got lost! Fixing this is something that's going to be next on our roadmap after the current set of features.

  17. added
    core
    on Sep 30, 2020
  18. self-assigned this
    on Oct 27, 2020
  19. vilmibm commented on Oct 28, 2020

    @vilmibm
    Contributor

    @ampinsk @mislav @samcoe i would like initial feedback on this draft PR 🙏 : #2313

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

Metadata

Metadata

Assignees

Labels

coreenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions