Skip to content

fix(config): better config parse errors#1691

Open
kawacukennedy wants to merge 2 commits into
floatpane:masterfrom
kawacukennedy:feat/friendly-config-error
Open

fix(config): better config parse errors#1691
kawacukennedy wants to merge 2 commits into
floatpane:masterfrom
kawacukennedy:feat/friendly-config-error

Conversation

@kawacukennedy

@kawacukennedy kawacukennedy commented Jul 20, 2026

Copy link
Copy Markdown

What?

Wrap config file parse errors with the file path, and replace the panic() in defaultKeybinds() with a logged warning.

Why?

Closes #1520

When a config file is malformed, the error only showed a raw JSON parse error with no indication of which file was broken. Users had no way to know what to fix.

If the embedded default_keybinds.json was somehow corrupted, the application crashed with a panic instead of degrading gracefully.

- Wrap the JSON parse error in LoadConfig with the config file path
  so users know which file has the problem (fixes floatpane#1520).
- Replace panic on malformed embedded default_keybinds.json with a
  logged warning that returns empty keybinds, preventing a crash
  from corrupted embedded data.
@kawacukennedy
kawacukennedy requested a review from a team as a code owner July 20, 2026 00:53

@floatpanebot floatpanebot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kawacukennedy! Please fix the following issues with your PR:

  • Title: Is too long (69 characters). The PR title must be strictly under 40 characters.
  • Body: Missing the ## What? or ## Why? headings required by the PR template.

@floatpanebot floatpanebot added the area/config Configuration / settings label Jul 20, 2026
@kawacukennedy kawacukennedy changed the title fix(config): wrap malformed config error with file path, remove panic fix(config): better config parse errors Jul 20, 2026
@floatpanebot
floatpanebot dismissed their stale review July 20, 2026 01:33

Formatting issues have been resolved. Thank you!

@floatpanebot floatpanebot added the size/XS Diff: 0–10 lines label Jul 20, 2026
@floatpanebot

Copy link
Copy Markdown
Member

Benchmark report — no significant change

Metrics worse: 0 · better: 0 (threshold: ±3%).

benchstat output
goos: linux
goarch: amd64
pkg: github.com/floatpane/matcha/backend
cpu: AMD EPYC 7763 64-Core Processor                
                           │   old.txt    │               new.txt               │
                           │    sec/op    │    sec/op     vs base               │
ParseSearchQuery_Simple-4    2.856µ ± 27%   2.102µ ± 25%  -26.39% (p=0.041 n=6)
ParseSearchQuery_Complex-4   8.137µ ± 33%   8.565µ ± 81%        ~ (p=0.589 n=6)
TokenizeSearchQuery-4        4.564µ ± 34%   4.444µ ± 36%        ~ (p=0.818 n=6)
geomean                      4.733µ         4.309µ         -8.97%

                           │  old.txt   │              new.txt               │
                           │    B/op    │    B/op     vs base                │
ParseSearchQuery_Simple-4    26.00 ± 0%   26.00 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   762.0 ± 0%   762.0 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        176.0 ± 0%   176.0 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      151.6        151.6       +0.00%
¹ all samples are equal

                           │  old.txt   │              new.txt               │
                           │ allocs/op  │ allocs/op   vs base                │
ParseSearchQuery_Simple-4    2.000 ± 0%   2.000 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   23.00 ± 0%   23.00 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        9.000 ± 0%   9.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      7.453        7.453       +0.00%
¹ all samples are equal

pkg: github.com/floatpane/matcha/tui
                    │   old.txt    │              new.txt               │
                    │    sec/op    │    sec/op     vs base              │
LogPanelView-4        182.2µ ± 15%   165.4µ ±  5%       ~ (p=0.180 n=6)
SearchOverlayView-4   173.4µ ± 10%   191.8µ ± 12%       ~ (p=0.065 n=6)
InboxConstruction-4   1.069m ± 18%   1.003m ±  6%       ~ (p=0.240 n=6)
geomean               323.2µ         316.8µ        -1.99%

                    │    old.txt    │               new.txt               │
                    │     B/op      │     B/op       vs base              │
LogPanelView-4        33.23Ki ± 34%   44.67Ki ±  0%       ~ (p=0.182 n=6)
SearchOverlayView-4   56.14Ki ± 41%   44.66Ki ± 26%       ~ (p=0.924 n=6)
InboxConstruction-4   874.3Ki ±  0%   874.3Ki ±  0%       ~ (p=0.699 n=6)
geomean               117.7Ki         120.4Ki        +2.27%

                    │   old.txt   │              new.txt              │
                    │  allocs/op  │  allocs/op   vs base              │
LogPanelView-4         713.0 ± 0%    714.0 ± 0%       ~ (p=0.182 n=6)
SearchOverlayView-4    926.0 ± 0%    925.0 ± 0%       ~ (p=1.000 n=6)
InboxConstruction-4   3.478k ± 0%   3.478k ± 0%       ~ (p=0.935 n=6)
geomean               1.319k        1.319k       +0.01%

auto-generated by benchmarks.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Configuration / settings size/XS Diff: 0–10 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEAT: Friendly error message on malformed config file

2 participants