Skip to content

Refuse a null chord in BindChord, ExecuteChord and FindCommandByChord whatever the profile [patch] - #231

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/230-null-chord-guard
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/230-null-chord-guard

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #230

What was wrong

KeybindingService checked the chord only after its early returns. When no profile was active, or the profile or command id was blank, a null chord came back as false/null. With a profile active, it threw ArgumentNullException. So a caller passing a null chord passed tests that set up no profile, then crashed in the app.

Change

  • Ensure.NotNull(chord) is now the first statement of all six chord-taking overloads: the active-profile and explicit-profile versions of BindChord, ExecuteChord and FindCommandByChord.
  • IKeybindingService lists ArgumentNullException for those six members.

Tests

New NullChordArgumentTests:

  • no active profile
  • active profile
  • blank, null and unknown profile id
  • blank command id

With the service change reverted, 7 of 9 cases fail. The active-profile case and the unknown-profile case already threw before this change, and they stay as guards.

Full suite on Linux / .NET 10: 390/390 passed.


Generated by Claude Code

… whatever the profile [patch]

The chord check ran after the blank-profile, blank-command and no-active-profile
early returns, so a null chord returned false/null in a test with no profile and
threw ArgumentNullException in an app with one. Every chord-taking overload now
checks the chord first, and IKeybindingService documents the exception.

Fixes #230

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW499sBmEvZWVdPTbTv

Copy link
Copy Markdown
Contributor Author

The github-advanced-security check failed, but the failure didn't come from this change. The job is GitHub's Copilot autofind action, and it exited with DOMException [TimeoutError]: The operation was aborted due to timeout inside autofind.js without reporting any finding. The same check passed on #228 this morning. CodeQL, Analyze (csharp) and the tests on Ubuntu, Windows and macOS all passed on this head.

I tried to re-run the job, but GitHub refused with "This workflow run cannot be retried", so this PR has no fix to push. A re-run from the Actions page, or the next push, should clear it.


Generated by Claude Code

@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants