What's wrong
KeybindingManager.InitializeAsync guards the stored active profile with IsNullOrEmpty (Keybinding/KeybindingManager.cs:103):
if (!string.IsNullOrEmpty(activeProfileId) && Profiles.ProfileExists(activeProfileId))
but ProfileManager.ProfileExists throws on whitespace (Keybinding/Services/ProfileManager.cs:128-131):
return string.IsNullOrWhiteSpace(profileId)
? throw new ArgumentException("Profile ID cannot be null or whitespace", nameof(profileId))
JsonKeybindingRepository.LoadActiveProfileAsync returns the stored id verbatim, so a whitespace id passes the first check and throws from the second.
Failure scenario
active-profile.json contains {"activeProfileId": " "}. It might have been hand-edited, or it might come from a custom IKeybindingRepository. InitializeAsync then throws ArgumentException: Profile ID cannot be null or whitespace. Commands and profiles have already been loaded at that point, so the manager is left half-initialized. A missing, unknown or corrupt active profile id loads without error. Only a blank one crashes.
This was missed alongside #125 and #133, which made invalid stored profiles, chords and commands get skipped instead of failing the load. The active-profile entry was not covered by those fixes.
Suggested fix / acceptance criteria
- Use
string.IsNullOrWhiteSpace at KeybindingManager.cs:103, or have LoadActiveProfileAsync return null for a blank id.
- Add a test next to the existing invalid-stored-entry tests. It loads a whitespace active profile id and expects
InitializeAsync to complete with no active profile set and no exception.
What's wrong
KeybindingManager.InitializeAsyncguards the stored active profile withIsNullOrEmpty(Keybinding/KeybindingManager.cs:103):but
ProfileManager.ProfileExiststhrows on whitespace (Keybinding/Services/ProfileManager.cs:128-131):JsonKeybindingRepository.LoadActiveProfileAsyncreturns the stored id verbatim, so a whitespace id passes the first check and throws from the second.Failure scenario
active-profile.jsoncontains{"activeProfileId": " "}. It might have been hand-edited, or it might come from a customIKeybindingRepository.InitializeAsyncthen throwsArgumentException: Profile ID cannot be null or whitespace. Commands and profiles have already been loaded at that point, so the manager is left half-initialized. A missing, unknown or corrupt active profile id loads without error. Only a blank one crashes.This was missed alongside #125 and #133, which made invalid stored profiles, chords and commands get skipped instead of failing the load. The active-profile entry was not covered by those fixes.
Suggested fix / acceptance criteria
string.IsNullOrWhiteSpaceatKeybindingManager.cs:103, or haveLoadActiveProfileAsyncreturnnullfor a blank id.InitializeAsyncto complete with no active profile set and no exception.