wagoodman/dive · error
failed to parse key %q: %w
Error message
failed to parse key %q: %w
What it means
Thrown by keybinding Config.Setup() when keybinding.ParseAll() cannot parse the configured key string. ParseAll splits the input on delimiters and translates each token into a gocui key; any unrecognized key name or modifier combination yields this error with the raw input quoted.
Source
Thrown at cmd/dive/cli/internal/ui/v1/key/config.go:20
import (
"fmt"
"github.com/awesome-gocui/keybinding"
)
type Config struct {
Input string
Keys []keybinding.Key `yaml:"-" mapstructure:"-"`
}
func (c *Config) Setup() error {
if len(c.Input) == 0 {
return nil
}
parsed, err := keybinding.ParseAll(c.Input)
if err != nil {
return fmt.Errorf("failed to parse key %q: %w", c.Input, err)
}
c.Keys = parsed
return nil
}
type Bindings struct {
Global GlobalBindings `yaml:",inline" mapstructure:",squash"`
Navigation NavigationBindings `yaml:",inline" mapstructure:",squash"`
Layer LayerBindings `yaml:",inline" mapstructure:",squash"`
Filetree FiletreeBindings `yaml:",inline" mapstructure:",squash"`
}
type GlobalBindings struct {
Quit Config `yaml:"quit" mapstructure:"quit"`
ToggleView Config `yaml:"toggle-view" mapstructure:"toggle-view"`
FilterFiles Config `yaml:"filter-files" mapstructure:"filter-files"`
CloseFilterFiles Config `yaml:"close-filter-files" mapstructure:"close-filter-files"`
}View on GitHub (pinned to d6c691947f)
Solutions
- Check the quoted input in the message and correct it to a single supported key spec such as 'tab', 'ctrl+t', 'f5', or 'ctrl+shift+d' as supported by the keybinding package.
- Avoid tool-specific notation (<C-a>, cmd+); use dive's documented key names.
- Test with one simple binding first, then restore the rest.
- Reset the keybinding section to defaults and re-apply changes incrementally.
Example fix
# before (dive.yaml)
keybinding:
global:
quit: <C-c> # vim-style -> failed to parse key "<C-c>"
# after
keybinding:
global:
quit: ctrl+c Defensive patterns
Strategy: validation
Validate before calling
# sanity-check key syntax before launch (dive uses gocui-style specs) grep -E '(<C-|cmd\+|meta\+)' dive.yaml && echo "unsupported key notation" && exit 1 || true
Prevention
- Use dive's documented key specs: 'ctrl+x', 'shift+tab', 'f1'..'f12', 'enter', 'esc'.
- Do not port vim/tmux/macOS notation directly.
- Introduce custom bindings one at a time to isolate parse failures.
When it happens
Trigger: A dive.yaml keybinding value with invalid key names or syntax: 'ctrl+shift+x' variants unsupported by the parser, typos like 'conrtol+a', platform-specific names ('cmd+f' on Linux), or stray characters after the key.
Common situations: Copy-pasting keybindings from another tool's config (vim/tmux syntax like '<C-a>'); macOS users porting cmd-based shortcuts; version changes that renamed keys.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- no keybinding configured for '%s'
- failed to unmarshal CI config file %s: %w
- unable to determine image source from %q: %v
- failed to read CI config file %s: %w
- controller failed update: %w
AI-assisted analysis of wagoodman/dive@d6c691947f (2026-08-15).
Data as JSON: /api/errors/bb2d6646b84dd6b3.
Report an issue: GitHub.