Skip invalid stored profiles and chords instead of failing the load - #153
Merged
Merged
Conversation
…patch] A well-formed profiles.json with an empty chord, a blank note, or a blank profile id or name threw ArgumentException out of LoadAllProfilesAsync, so KeybindingManager.InitializeAsync and SaveAsync failed while a syntactically corrupt file was tolerated. Convert each profile and chord on its own, skip the invalid ones, and write a debug line naming each skipped entry. Fixes #125 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WAdbE4VMmkBh1tzMGpC9Wy
|
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 #125
Problem
JsonKeybindingRepository.LoadAllProfilesInternalAsynccaught onlyJsonException. A well-formedprofiles.jsonthat holds a chord with no notes, a blank note, or a profile with a blank id or name threwArgumentExceptionfrom the model constructors.KeybindingManager.InitializeAsyncfailed, and so didSaveAsync, because saving reloads the file first. A syntactically corrupt file was handled without error.Change
ToProfile). AnArgumentExceptionskips only the entry that caused it, so the rest of the file still loads.Debug.WriteLinewith the id and the reason, followingAsyncBatchHelper. The doc comment notes that a later save does not write skipped entries back.nullprofile entry or anullnotes array is treated as invalid and skipped, so it no longer causes aNullReferenceException.Tests
InvalidStoredProfileEntryTestscovers:With the fix reverted, 4 of the new tests fail. The corrupt-file test passes either way, because that path already worked. With the fix, the whole suite passes: 133 of 133.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WAdbE4VMmkBh1tzMGpC9Wy
Generated by Claude Code