Skip to content
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

Editing a gpg signed commit message via a Editor crashes #3490

Open
chmouel opened this issue Apr 11, 2024 · 1 comment
Open

Editing a gpg signed commit message via a Editor crashes #3490

chmouel opened this issue Apr 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@chmouel
Copy link

chmouel commented Apr 11, 2024

Describe the bug
A clear and concise description of what the bug is.

When editing a GPG signed commit, and doing C-o e to Open in Editor lazygit crash

2024/04/11 08:53:21 An error occurred! Please create an issue at: https://github.com/jesseduffield/lazygit/issues

*errors.errorString Feature not available for users using GPG
github.com/jesseduffield/lazygit/pkg/commands/git_commands/rebase.go:357 (0x1054c2084)
github.com/jesseduffield/lazygit/pkg/gui/controllers/local_commits_controller.go:379 (0x1055fce68)
github.com/jesseduffield/lazygit/pkg/gui/context/commit_message_context.go:134 (0x105599ce4)
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/commits_helper.go:108 (0x105599cad)
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/commits_helper.go:228 (0x10559a840)
github.com/jesseduffield/lazygit/pkg/gui/context/menu_context.go:169 (0x10550c388)
github.com/jesseduffield/lazygit/pkg/gui/controllers/menu_controller.go:73 (0x105606a30)
github.com/jesseduffield/lazygit/pkg/gui/controllers/list_controller_trait.go:112 (0x105606408)
github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:445 (0x1056614d8)
github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:398 (0x105661184)
github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:392 (0x105661074)
github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:1456 (0x1052c0bd0)
github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:1424 (0x1052c0a80)
github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:1281 (0x1052c0088)
github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:800 (0x1052be754)
github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:754 (0x1052be3a8)
github.com/jesseduffield/gocui@v0.3.1-0.20240309085756-86e0d5a312de/gui.go:741 (0x1052be14c)
github.com/jesseduffield/lazygit/pkg/gui/gui.go:705 (0x10565993c)
github.com/jesseduffield/lazygit/pkg/gui/gui.go:711 (0x105659ec0)
github.com/jesseduffield/lazygit/pkg/utils/utils.go:117 (0x1053711a0)
github.com/jesseduffield/lazygit/pkg/gui/gui.go:710 (0x105659e2c)
github.com/jesseduffield/lazygit/pkg/app/app.go:266 (0x105683d5c)
github.com/jesseduffield/lazygit/pkg/app/app.go:49 (0x105683d21)
github.com/jesseduffield/lazygit/pkg/app/entry_point.go:150 (0x10568595c)
github.com/jesseduffield/lazygit/main.go:23 (0x105687398)
runtime/internal/atomic/types.go:194 (0x104fe514c)
runtime/asm_arm64.s:1222 (0x10501a244)

To Reproduce
Steps to reproduce the behavior:

  1. Edit a GPG signed commit
  2. Do C-o
  3. Do e
  4. see the crash

Expected behavior
not crashing

Screenshots
If applicable, add screenshots to help explain your problem.

Version info:

commit=, build date=, build source=homebrew, version=0.41.0, os=darwin, arch=arm64, git version=2.44.0

Additional context
Add any other context about the problem here.

Note: please try updating to the latest version or manually building the latest master to see if the issue still occurs.

@chmouel chmouel added the bug Something isn't working label Apr 11, 2024
@stefanhaller
Copy link
Collaborator

What happens here is that the <c-o> handler tries to throw the error "Feature not available for users using GPG", but nobody catches it, and so it bubbles up all the way into gocui, which panics seeing the error.

Which means that there are two potential solutions to this bug:

  1. Make it actually work
  2. Make it show the error message that the command is not supported, without crashing

The first of these is tricky and requires more work (see here; I'm not really sure I understand that comment though...).

The second is much easier, all it takes is a call to c.Error(err) at the appropriate point in the call chain. A good place might be in MenuController.press(). However, an even better fix would be to do #3491, this would solve it once and for all everywhere.

stefanhaller added a commit that referenced this issue Apr 18, 2024
- **PR Description**

Simplify and canonicalize error handling across the code base.

Previously it was important to make sure that errors don't bubble up
into gocui, because it would panic there; so we had to show errors in
error panels in the right places (in controller code, usually). This is
error-prone because it's easy to forget (see #3490 for an example);
also, it's not always obvious where in the call chain the error panel
needs to be shown. Most of the time it's in controller code, but we had
plenty of calls to `Error()` in helpers, and I remember that I found
this very confusing when I was new to the code base.

Change this so that you can simply return errors everywhere. The
functions to show an error message manually have been removed for
clarity.

I tried to structure the commits so that you can review them one by one.

Closes #3491.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants