You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
One invalid or null entry in commands.json makes KeybindingManager.InitializeAsync throw, although a syntactically corrupt commands.json is tolerated #133
This is the commands.json counterpart of #125, which covers only profiles.json. JsonKeybindingRepository.LoadCommandsAsync (Keybinding/Services/JsonKeybindingRepository.cs:~170-195) catches only JsonException. Inside the same try, .Select(dto => new Command(dto.Id, dto.Name, dto.Description, dto.Category)) throws ArgumentException for a blank id or name, and NullReferenceException for a null array element. KeybindingManager.InitializeAsync loads commands before profiles, so the whole startup fails.
Repro (verified against the built library)
With a valid profiles.json in place, write commands.json and call await new KeybindingManager(dir).InitializeAsync():
ArgumentException: Command ID cannot be null or whitespace
the invalid entry is skipped
[{"id":"file.save","name":"Save"},null]
NullReferenceException
the null entry is skipped
Why it matters
A single hand-edited or partially migrated entry prevents the application from starting. A file that is completely unparseable is handled gracefully, so the behaviour is also inconsistent.
Suggested fix
Convert each DTO in its own guarded step: skip null DTOs, and catch ArgumentException per entry so a bad entry is dropped rather than failing the load. The same pattern fits #125. Note that profiles.json also has null-shaped cases that throw NullReferenceException/ArgumentNullException ([null], "chords":{"a":null}, "notes":null), so catching ArgumentException alone would not be enough there either.
Acceptance: each of the three bad inputs above loads file.save and InitializeAsync does not throw. Add tests next to the existing corrupted-file test.
Activity
matt-edmondson commentedon Sep 27, 2026
Triage
JsonKeybindingRepositorypersistence. Owner: @matt-edmondsonArgumentExceptionper entry, then add the three repro inputs as tests next to the corrupted-file test.Generated by Claude Code