Skip to content

panic in exp multiselect prompt-example #560

@johnstcn

Description

@johnstcn

This is tricky to reproduce, but it looks like the multiselectModel can panic in some circumstances:

(Note: this is with no default set)

                                                Options: []string{
                                                        "Code", "Chairs", "Whale", "Diamond", "Carrot",
                                                },
-                                               Defaults:          []string{"Code"},
+                                               // Defaults:          []string{"Code"},
                                                EnableCustomInput: enableCustomInput,
                                        })
$ go run ./cmd/coder exp prompt-example multi-select --enable-custom-input
? Select some things:  [Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
  [x] Code
  [ ] Chairs
  [x] Whale
  [ ] Diamond
  [ ] Carrot
>  + Add custom value
Caught panic:

runtime error: index out of range [5] with length 5

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
	/Users/cian/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:26 +0x64
runtime/debug.PrintStack()
	/Users/cian/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:18 +0x1c
github.com/charmbracelet/bubbletea.(*Program).recoverFromPanic(0x14000482000)
	/Users/cian/go/pkg/mod/github.com/coder/[email protected]/tea.go:705 +0x80
panic({0x104954580?, 0x14000736f90?})
	/Users/cian/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:792 +0x124
github.com/coder/coder/v2/cli/cliui.multiSelectModel.Update({{{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, 0x0, 0x2a, {0x1f972880, {0x0, ...}, ...}, ...}, ...}, ...)
	/Users/cian/src/coder/coder/cli/cliui/select.go:423 +0x6bc
github.com/charmbracelet/bubbletea.(*Program).eventLoop(0x14000482000, {0x104b4e0c0?, 0x14000161508?}, 0x1400005a7e0)
	/Users/cian/go/pkg/mod/github.com/coder/[email protected]/tea.go:461 +0x644
github.com/charmbracelet/bubbletea.(*Program).Run(0x14000482000)
	/Users/cian/go/pkg/mod/github.com/coder/[email protected]/tea.go:595 +0x8cc
github.com/coder/coder/v2/cli/cliui.MultiSelect(0x14000121200, {{0x102f65fb9, 0x13}, {0x140005ae2d0, 0x5, 0x5}, {0x0, 0x0, 0x0}, 0x1})
	/Users/cian/src/coder/coder/cli/cliui/select.go:352 +0x414
github.com/coder/coder/v2/cli.RootCmd.promptExample.func8(0x14000121200)
	/Users/cian/src/coder/coder/cli/exp_prompts.go:165 +0x114
github.com/coder/coder/v2/cli.RootCmd.promptExample.RootCmd.promptExample.func1.func15(0xc8?)
	/Users/cian/src/coder/coder/cli/exp_prompts.go:20 +0x24
github.com/coder/coder/v2/cli.(*RootCmd).Command.func6.1(0x0?)
	/Users/cian/src/coder/coder/cli/root.go:319 +0xb8
github.com/coder/coder/v2/cli.(*RootCmd).Command.func7.PrintDeprecatedOptions.1.1(0x14000121200)
	/Users/cian/src/coder/coder/cli/root.go:1361 +0x130
github.com/coder/serpent.(*Invocation).run(0x14000121200, 0x14000571c48)
	/Users/cian/go/pkg/mod/github.com/coder/[email protected]/command.go:499 +0x1224
github.com/coder/serpent.(*Invocation).run(0x14000120700, 0x14000571c48)
	/Users/cian/go/pkg/mod/github.com/coder/[email protected]/command.go:419 +0x858
github.com/coder/serpent.(*Invocation).run(0x14000120700, 0x14000571c48)
	/Users/cian/go/pkg/mod/github.com/coder/[email protected]/command.go:419 +0x858
github.com/coder/serpent.(*Invocation).run(0x14000120700, 0x14000571c48)
	/Users/cian/go/pkg/mod/github.com/coder/[email protected]/command.go:419 +0x858
github.com/coder/serpent.(*Invocation).Run(0x14000120700)
	/Users/cian/go/pkg/mod/github.com/coder/[email protected]/command.go:594 +0x10c
github.com/coder/coder/v2/cli.(*RootCmd).RunWithSubcommands(0x1400064de60, {0x1400073e008, 0x2c, 0x57})
	/Users/cian/src/coder/coder/cli/root.go:166 +0x354
main.main()
	/Users/cian/src/coder/coder/cmd/coder/main.go:26 +0x134
"" are nice choices.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions