What's wrong
The active-profile overloads in Keybinding/Services/KeybindingService.cs don't guard commandId:
GetChord(commandId) (~line 93)
UnbindChord(commandId) (~line 131)
HasChordBinding(commandId) (~line 253)
They forward to Profile.GetChord, Profile.RemoveChord and Profile.HasChord, which throw ArgumentException on whitespace. The (profileId, commandId) overloads check string.IsNullOrWhiteSpace(commandId) and return null or false.
Reproduction
svc.UnbindChord(" "); // no active profile -> false
svc.SetActiveProfile("p");
svc.UnbindChord(" "); // -> throws ArgumentException
svc.GetChord(" "); // -> throws ArgumentException
svc.GetChord("p", " "); // -> null
This was reproduced with a temporary MSTest test.
Why it matters
The result for the same input depends on whether a profile happens to be active, which is hidden state. The documented contract for UnbindChord is "false if it didn't exist or no active profile", and a caller that follows it can crash. The one-argument and two-argument overloads also disagree for identical inputs.
This is separate from #123. That issue is about a Command whose id has surrounding whitespace; this one is about blank ids passed to the lookup and unbind methods.
Suggested fix
Add the same if (string.IsNullOrWhiteSpace(commandId)) return null/false; guard that the profile-id overloads use.
Acceptance: for a blank commandId, the one-argument overloads return the same result as the two-argument ones, whether or not a profile is active.
What's wrong
The active-profile overloads in
Keybinding/Services/KeybindingService.csdon't guardcommandId:GetChord(commandId)(~line 93)UnbindChord(commandId)(~line 131)HasChordBinding(commandId)(~line 253)They forward to
Profile.GetChord,Profile.RemoveChordandProfile.HasChord, which throwArgumentExceptionon whitespace. The(profileId, commandId)overloads checkstring.IsNullOrWhiteSpace(commandId)and returnnullorfalse.Reproduction
This was reproduced with a temporary MSTest test.
Why it matters
The result for the same input depends on whether a profile happens to be active, which is hidden state. The documented contract for
UnbindChordis "false if it didn't exist or no active profile", and a caller that follows it can crash. The one-argument and two-argument overloads also disagree for identical inputs.This is separate from #123. That issue is about a
Commandwhose id has surrounding whitespace; this one is about blank ids passed to the lookup and unbind methods.Suggested fix
Add the same
if (string.IsNullOrWhiteSpace(commandId)) return null/false;guard that the profile-id overloads use.Acceptance: for a blank
commandId, the one-argument overloads return the same result as the two-argument ones, whether or not a profile is active.