-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#315 fix: cursor error when go-blueprint create fails #318
Conversation
Your PR didn't solve the issue. Try testing it, for example, by using a path where go.mod doesn't exist in program.go on purpose: // Create go.mod
err = utils.InitGoMod(p.ProjectName, gitHubActionPath)
if err != nil {
log.Printf("Could not initialize go.mod in new project %v\n", err)
cobra.CheckErr(err)
return err
} go build Create the project....blueprint errors out, and the terminal still doesn't display visible input. |
Code snippet: Thank you for the code snippet. I understand your concern about the potential bug scenario. However, as per my understanding we do not offer any flag to ask user for project path so this case would only occur if someone intentionally modifies the code to match the provided snippet, which would deviate from our intended implementation. Should we still add additional safeguards for such edge cases, or do you think the current implementation sufficiently handles the expected use cases? |
@Ujstor I would like to know your thoughts |
My point was that returning the "raw" error will not solve the issue. I stretched my example just to prove the point. I don't know what went wrong in #315, but it can happen, and users will experience the issue. If you completely remove the spinner from the codebase, the bug disappears. That's how I know the spinner itself causes this issue. In the end, we have duplication in the codebase, there is no need to return an error and use cobra.CheckErr. The codebase is the result of work from many contributors, and things like this sneak in over time. Maybe it's time for a refactor ;) |
Indeed |
@vinitparekh17 Would you like to dig deeper into the problem and try to find a possible solution, or should I close the PR? |
I would like to resolve this issue, might need some time and suggestions |
@Ujstor I've tested it with your snippet, and it's now working without breaking. I've just updated the error handling in create.go to use |
simple explaination
|
Unfortunately, this is not a valid solution. The cobra library is one of the core components, and it is used for a reason. |
Indeed and I just made sure that we use err = project.CreateMainFile()
if err != nil {
if releaseErr := spinner.ReleaseTerminal(); releaseErr != nil {
log.Printf("Problem releasing terminal: %v", releaseErr)
}
log.Printf("Problem creating files for project. %v", err)
cobra.CheckErr(textinput.CreateErrorInputModel(err).Err())
}
I manually tested this with your snippet as well as by my own scenarios and it shows error as it was, before releasing cursor. |
Thanks for the feedback. I need to review this in detail, and I hope to manage it by the end of the week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and tested your implementation, and you are right, the error was not handled correctly in program.go. Very, very nice bug hunt!
LGTM!!
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.
Problem/Feature
This PR resolves issue #315
Description of Changes:
In the
CreateMainFile
function located in/cmd/program/program.go
, the error handling has been updated to ensure the terminal is properly released. Specifically:err
so that thespinner.ReleaseTerminal()
call can be executed ( create.go line 273 ), ensuring the terminal is released even in the event of an error.This change helps prevent terminal lock-ups by ensuring proper cleanup
Checklist