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

chezmoi diff panics with tea.unknownCSISequenceMsg: unknown message type #3662

Open
triallax opened this issue Mar 27, 2024 · 6 comments
Open
Labels
bug Something isn't working in dependency In a dependency, not in chezmoi

Comments

@triallax
Copy link
Contributor

triallax commented Mar 27, 2024

Note: this issue seems to have resolved itself after I ran chezmoi update, but I wanted to open a ticket anyway for posterity's sake.

Describe the bug

chezmoi diff panics, here's its output:

diff --git a/.config/helix/languages.toml b/.config/helix/languages.toml
index d9539f111281d0c36a7c4164348f56e100692a52..90592794ed039bb6b29e932c07f925854293579d 100644
--- a/.config/helix/languages.toml
+++ b/.config/helix/languages.toml
@@ -23,10 +23,3 @@
 [[language]]
 name = "gotmpl"
 file-types = ["gotmpl", "tmpl", ".chezmoiexternal.toml", ".chezmoiignore", ".chemzoiremove"]
-
-[[language]]
-name = "hare"
-language-servers = [ {name = "hare-lsp"} ]
-
-[language-server.hare-lsp]
-command = "hals"
                                              Caught panic:

tea.unknownCSISequenceMsg: unknown message type

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
        runtime/debug/stack.go:16 +0x13
github.com/charmbracelet/bubbletea.(*Program).Run.func1()
        github.com/charmbracelet/bubbletea@v0.25.0/tea.go:478 +0x91
panic({0x5870b56b69e0?, 0xc000052030?})
        runtime/panic.go:770 +0x132
github.com/twpayne/chezmoi/v2/internal/cmd.httpSpinnerModel.Update({{0xc00004a660, 0x53}, {{{0xc000204f08, 0x4a, 0x4a}, 0xfe502a}, {0x0, 0x0, {0x0, 0x0}}, ...}, ...}, ...)
        github.com/twpayne/chezmoi/v2/internal/cmd/readhttpresponse.go:107 +0x514
github.com/charmbracelet/bubbletea.(*Program).eventLoop(0xc0001181a0, {0x5870b5922890?, 0xc00051e070?}, 0xc00004a7e0)
        github.com/charmbracelet/bubbletea@v0.25.0/tea.go:411 +0x5e2
github.com/charmbracelet/bubbletea.(*Program).Run(0xc0001181a0)
        github.com/charmbracelet/bubbletea@v0.25.0/tea.go:543 +0x86b
github.com/twpayne/chezmoi/v2/internal/cmd.runReadHTTPResponse({0x5870b5925a00?, 0xc00051e070?}, 0xc00013e7e0)
        github.com/twpayne/chezmoi/v2/internal/cmd/readhttpresponse.go:184 +0x18f
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).readHTTPResponse(0xc000277008?, 0xc00013e7e0)
        github.com/twpayne/chezmoi/v2/internal/cmd/readhttpresponse.go:151 +0x3e5
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).getExternalDataRaw(0xc000002000, {0x5870b5925ae0, 0x5870b646e3a0}, {{0xc0005329a8?, 0x550c7dc3243185be?}}, 0xc000186ea0, 0xc000661140)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1569 +0x414
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).getExternalData(0xc000002000, {0x5870b5925ae0?, 0x5870b646e3a0?}, {{0xc0005329a8?, 0x767d28d58108?}}, 0xc000186ea0, 0xc000580008?)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1600 +0x5a
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).readExternalFile.func1()
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:2624 +0x2f
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*lazyContents).Contents(0xc0002a5130)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/lazy.go:77 +0x33
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*TargetStateFile).EntryState(0xc0004071a0, 0x12)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/targetstateentry.go:234 +0x26
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).Apply(0xc000002000, {0x5870b592e8c0, 0xc0000eb200}, {0x5870b592e8c0, 0xc0000eb200}, {0x5870b592b7f8, 0xc000520430}, {0xc0000460dd, 0xe}, {{0xc000533e60, ...}}, ...)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:687 +0x1e3
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).applyArgs(0xc000277008, {0x5870b5925ae0, 0x5870b646e3a0}, {0x5870b592e8c0, 0xc0000eb200}, {0xc0000460dd, 0xe}, {0x5870b646e3a0, 0x0, 0x0}, ...)
        github.com/twpayne/chezmoi/v2/internal/cmd/config.go:651 +0x68f
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).runDiffCmd(0xc000277008, 0xc0005c1808, {0x5870b646e3a0, 0x0, 0x0})
        github.com/twpayne/chezmoi/v2/internal/cmd/diffcmd.go:49 +0x1c8
github.com/spf13/cobra.(*Command).execute(0xc0005c1808, {0x5870b646e3a0, 0x0, 0x0})
        github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc000121508)
        github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).execute(0xc00071fde8?, {0xc000126010, 0x1, 0x1})
        github.com/twpayne/chezmoi/v2/internal/cmd/config.go:1202 +0x78
github.com/twpayne/chezmoi/v2/internal/cmd.runMain({{0x5870b4526c90, 0x6}, {0x5870b4527c58, 0x7}, {0x0, 0x0}, {0x0, 0x0}}, {0xc000126010, 0x1, ...})
        github.com/twpayne/chezmoi/v2/internal/cmd/cmd.go:269 +0x25c
github.com/twpayne/chezmoi/v2/internal/cmd.Main({{0x5870b4526c90, 0x6}, {0x5870b4527c58, 0x7}, {0x0, 0x0}, {0x0, 0x0}}, {0xc000126010, 0x1, ...})
        github.com/twpayne/chezmoi/v2/internal/cmd/cmd.go:105 +0xa5
main.main()
        github.com/twpayne/chezmoi/v2/main.go:24 +0xfb
panic: interface conversion: interface is nil, not cmd.cancelableModel

goroutine 1 [running]:
github.com/twpayne/chezmoi/v2/internal/cmd.runReadHTTPResponse({0x5870b5925a00?, 0xc00051e070?}, 0xc00013e7e0)
        github.com/twpayne/chezmoi/v2/internal/cmd/readhttpresponse.go:186 +0x25d
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).readHTTPResponse(0xc000277008?, 0xc00013e7e0)
        github.com/twpayne/chezmoi/v2/internal/cmd/readhttpresponse.go:151 +0x3e5
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).getExternalDataRaw(0xc000002000, {0x5870b5925ae0, 0x5870b646e3a0}, {{0xc0005329a8?, 0x550c7dc3243185be?}}, 0xc000186ea0, 0xc000661140)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1569 +0x414
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).getExternalData(0xc000002000, {0x5870b5925ae0?, 0x5870b646e3a0?}, {{0xc0005329a8?, 0x767d28d58108?}}, 0xc000186ea0, 0xc000580008?)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:1600 +0x5a
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).readExternalFile.func1()
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:2624 +0x2f
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*lazyContents).Contents(0xc0002a5130)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/lazy.go:77 +0x33
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*TargetStateFile).EntryState(0xc0004071a0, 0x12)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/targetstateentry.go:234 +0x26
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).Apply(0xc000002000, {0x5870b592e8c0, 0xc0000eb200}, {0x5870b592e8c0, 0xc0000eb200}, {0x5870b592b7f8, 0xc000520430}, {0xc0000460dd, 0xe}, {{0xc000533e60, ...}}, ...)
        github.com/twpayne/chezmoi/v2/internal/chezmoi/sourcestate.go:687 +0x1e3
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).applyArgs(0xc000277008, {0x5870b5925ae0, 0x5870b646e3a0}, {0x5870b592e8c0, 0xc0000eb200}, {0xc0000460dd, 0xe}, {0x5870b646e3a0, 0x0, 0x0}, ...)
        github.com/twpayne/chezmoi/v2/internal/cmd/config.go:651 +0x68f
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).runDiffCmd(0xc000277008, 0xc0005c1808, {0x5870b646e3a0, 0x0, 0x0})
        github.com/twpayne/chezmoi/v2/internal/cmd/diffcmd.go:49 +0x1c8
github.com/spf13/cobra.(*Command).execute(0xc0005c1808, {0x5870b646e3a0, 0x0, 0x0})
        github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc000121508)
        github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).execute(0xc00071fde8?, {0xc000126010, 0x1, 0x1})
        github.com/twpayne/chezmoi/v2/internal/cmd/config.go:1202 +0x78
github.com/twpayne/chezmoi/v2/internal/cmd.runMain({{0x5870b4526c90, 0x6}, {0x5870b4527c58, 0x7}, {0x0, 0x0}, {0x0, 0x0}}, {0xc000126010, 0x1, ...})
        github.com/twpayne/chezmoi/v2/internal/cmd/cmd.go:269 +0x25c
github.com/twpayne/chezmoi/v2/internal/cmd.Main({{0x5870b4526c90, 0x6}, {0x5870b4527c58, 0x7}, {0x0, 0x0}, {0x0, 0x0}}, {0xc000126010, 0x1, ...})
        github.com/twpayne/chezmoi/v2/internal/cmd/cmd.go:105 +0xa5
main.main()
        github.com/twpayne/chezmoi/v2/main.go:24 +0xfb

To reproduce

I don't really know how to reproduce this, just running chezmoi diff triggered the panic for me.

Expected behavior

chezmoi diff doesn't panic.

Output of command with the --verbose flag

I didn't get to do this before the issue was fixed >:(

Output of chezmoi doctor

(After the issue was fixed)

$ chezmoi doctor
RESULT    CHECK                       MESSAGE
ok        version                     v2.47.2, commit v2.47.2
ok        latest-version              v2.47.2
ok        os-arch                     linux/amd64 (Chimera)
ok        uname                       Linux satoru 6.6.18-0-generic #1 SMP PREEMPT_DYNAMIC Fri Feb 23 18:35:06 UTC 2024 x86_64
ok        go-version                  go1.22.1 (gc)
ok        executable                  /usr/bin/chezmoi
ok        config-file                 ~/.config/chezmoi/chezmoi.toml, last modified 2023-12-10T02:03:04Z
warning   source-dir                  ~/.local/share/chezmoi is a git working tree (dirty)
ok        suspicious-entries          no suspicious entries
warning   working-tree                ~/.local/share/chezmoi is a git working tree (dirty)
ok        dest-dir                    ~ is a directory
ok        umask                       022
ok        cd-command                  found /bin/sh
ok        cd-args                     /bin/sh
info      diff-command                not set
ok        edit-command                found /usr/bin/hx
ok        edit-args                   /usr/bin/hx
ok        git-command                 found /usr/bin/git, version 2.44.0
warning   merge-command               vimdiff not found in $PATH
ok        shell-command               found /bin/sh
ok        shell-args                  /bin/sh
info      age-command                 age not found in $PATH
ok        gpg-command                 found /usr/bin/gpg, version 2.4.5
info      pinentry-command            not set
info      1password-command           op not found in $PATH
info      bitwarden-command           bw not found in $PATH
info      bitwarden-secrets-command   bws not found in $PATH
info      dashlane-command            dcli not found in $PATH
info      doppler-command             doppler not found in $PATH
info      gopass-command              gopass not found in $PATH
info      keepassxc-command           keepassxc-cli not found in $PATH
info      keepassxc-db                not set
info      keeper-command              keeper not found in $PATH
info      lastpass-command            lpass not found in $PATH
info      pass-command                pass not found in $PATH
info      passhole-command            ph not found in $PATH
info      rbw-command                 rbw not found in $PATH
info      vault-command               vault not found in $PATH
info      vlt-command                 vlt not found in $PATH
info      secret-command              not set

Additional context

Terminal is GNOME Console.

@triallax triallax changed the title chezmoi diff panics chezmoi diff panics with tea.unknownCSISequenceMsg: unknown message type Mar 27, 2024
@twpayne twpayne added bug Something isn't working in dependency In a dependency, not in chezmoi labels Mar 27, 2024
@twpayne
Copy link
Owner

twpayne commented Mar 27, 2024

Thanks for reporting this. This is a bug in charmbracelet/bubbletea that chezmoi uses for its interactive input.

The version of bubbletea has not changed, so the bug is still present.

Do you have any way to reproduce it?

@ErrrorMaxx
Copy link

ErrrorMaxx commented Mar 27, 2024

Probably can be reproduced with big diff output, somewhat slow pager (delta) and mouse input before diff appears at screen.

I am not 100% sure about this method, but I previously got this error with this conditions

@triallax
Copy link
Contributor Author

Do you have any way to reproduce it?

I have no idea unfortunately, I'm still not quite sure what triggered the bug in the first place.

Probably can be reproduced with big diff output, somewhat slow pager (delta) and mouse input before diff appears at screen.

I don't think mouse input is related, I was able to get this consistently on every chezmoi diff call. Also, my pager is less, which I don't think is slow.

@triallax
Copy link
Contributor Author

triallax commented Mar 27, 2024

Actually, I could restore from my backup yesterday and see if I can reproduce the panic, I'll try that.

@triallax
Copy link
Contributor Author

triallax commented Mar 27, 2024

https://github.com/charmbracelet/bubbletea/blob/3e050bbad12f880dbe960129d20663ecd836e775/key.go#L544

I suspect this means that something in the diff/one of my files was triggering the error (supported by the fact that chezmoi update fixed it).

@triallax
Copy link
Contributor Author

Yeah I couldn't reproduce it unfortunately, they I'm sure it's not about the diff length because I had a huge diff at one point and that didn't crash chezmoi diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in dependency In a dependency, not in chezmoi
Projects
None yet
Development

No branches or pull requests

3 participants