Skip invalid stored commands instead of failing the load [patch] - #160
Merged
Merged
Conversation
LoadCommandsAsync caught only JsonException, so a commands.json entry with a blank id or name (ArgumentException) or a null element (NullReferenceException) made KeybindingManager.InitializeAsync throw, although a file that is not JSON at all loaded as empty. Each entry is now converted on its own, the same way profiles.json entries are since #125, so a bad entry is dropped and the rest load. Fixes #133 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019UNSUUrn4o84JfkEVaD3xg
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #133
Problem
JsonKeybindingRepository.LoadCommandsAsynccaught onlyJsonException. So acommands.jsonentry with a blank id or name (ArgumentException), or anullarray element (NullReferenceException), madeKeybindingManager.InitializeAsyncthrow. A file that isn't JSON at all loaded fine, as empty.Change
Added
ToCommand, the commands counterpart of theToProfilehelper from #125/#153. It converts each DTO on its own:nullDTO is skippedArgumentExceptionis dropped, with aDebug.WriteLineThe rest of the file loads. As with profiles, a skipped entry is not written back by a later save.
Tests
New
InvalidStoredCommandEntryTests, alongsideInvalidStoredProfileEntryTests:nullentry) each loadfile.save, andInitializeAsyncdoes not throw. All three fail onmainand pass with the fix.main.commands.jsonstill loads zero commands. This is a regression guard and passes both before and after.The full suite passes locally: 139/139.
🤖 Generated with Claude Code
https://claude.ai/code/session_019UNSUUrn4o84JfkEVaD3xg
Generated by Claude Code