{"record":{"id":"6b7bdbdf3aadc5f5","repo":"kovidgoyal/kitty","slug":"invalid-previewer-specification-v-with-error","errorCode":null,"errorMessage":"invalid previewer specification: %#v with error: %w","messagePattern":"invalid previewer specification: %#v with error: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/choose_files/main.go","lineNumber":297,"sourceCode":"type previewer struct {\n\tcmdline      []string\n\tpattern      string\n\tuse_mimetype bool\n}\n\nfunc (p previewer) matches(fname, mt string) bool {\n\tq := utils.IfElse(p.use_mimetype, mt, fname)\n\tmatched, err := filepath.Match(p.pattern, q)\n\treturn matched && err == nil\n}\n\nvar previewers []previewer\n\nfunc load_previewers(cfg *Config) (err error) {\n\tfor _, spec := range cfg.Previewer {\n\t\tparts, err := shlex.Split(spec)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid previewer specification: %#v with error: %w\", spec, err)\n\t\t}\n\t\tif len(parts) < 2 {\n\t\t\treturn fmt.Errorf(\"invalid previewer specification: %#v with error: no command specified\", spec)\n\t\t}\n\t\tprefix, pattern, found := strings.Cut(parts[0], \":\")\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"invalid previewer specification: %#v with error: no prefix in pattern specification\", spec)\n\t\t}\n\t\tpreviewers = append(previewers, previewer{parts[1:], pattern, prefix == \"mime\"})\n\t}\n\treturn\n}\n\nfunc load_config(opts *Options) (ans *Config, err error) {\n\tans = NewConfig()\n\tp := config.ConfigParser{LineHandler: ans.Parse}\n\terr = p.LoadConfig(\"choose-files.conf\", opts.Config, opts.Override)\n\tif err != nil {","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/choose_files/main.go#L279-L315","documentation":"A previewer entry in the choose-files config failed shell-style tokenization by shlex.Split — the spec string has unbalanced quotes or invalid shell syntax, so it cannot be split into prefix:pattern plus command.","triggerScenarios":"Configuring --previewer 'name:{pattern} cmd' where the spec contains unterminated quotes or stray shell metacharacters that shlex rejects.","commonSituations":"Quoting mistakes in kitty.conf or CLI --previewer arguments, e.g. embedding a command with an unmatched single quote.","solutions":["Fix the quoting in the previewer spec so shlex can parse it (balance all quotes)","Test the spec string with a shell: echo of the command should tokenize cleanly","Simplify the spec: avoid nested quotes, use a wrapper script instead"],"exampleFix":"# before\n--previewer 'mime:image/* chafa -s {{columns}}x{{rows}} '\"'\"'file with spaces'\"'\"''\n# after\n--previewer 'mime:image/* preview-image.sh'","handlingStrategy":"validation","validationCode":"if _, err := shlex.Split(spec); err != nil { return fmt.Errorf(\"bad quoting in previewer spec: %v\", err) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint kitten config at startup","Prefer wrapper scripts over heavily-quoted inline commands"],"tags":["kitty","config","shlex","choose-files"],"backgroundTag":"config-parse-error","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}