Skip to content

Reject blank input in ParsePhrase with its own argument name - #132

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/parse-phrase-empty-128
Sep 27, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/parse-phrase-empty-128

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #128

What changed

KeybindingService.ParsePhrase had an empty-input guard that returned new Phrase([]). The Phrase constructor rejects an empty sequence, so that branch never returned. Every null, "" or whitespace call threw ArgumentException: Phrase must contain at least one chord (Parameter 'sequence'), which names a parameter the caller never passed.

This takes the minimal option from the issue and its triage comment. The guard now throws ArgumentException("Phrase string cannot be null or whitespace", nameof(phraseString)), the same contract ParseChord uses for chordString. The public signature stays the same. Blank input still throws ArgumentException, but the message and ParamName are now correct. The interface doc gains the matching <exception> tag.

If a Phrase?/TryParsePhrase API is wanted later, that's a separate API decision, left to the maintainer.

Tests

ParsePhraseEmptyInputTests checks that "", " " and null throw ArgumentException with ParamName == "phraseString". All three fail on main, where ParamName is sequence, and pass with the fix. The full suite passes: 90/90.

🤖 Generated with Claude Code

https://claude.ai/code/session_01G89GFC9HBcemu37GarNas1


Generated by Claude Code

The empty-input guard returned new Phrase([]), which the Phrase
constructor rejects, so every blank call threw an ArgumentException naming
the constructor's internal 'sequence' parameter. The guard now throws for
'phraseString', as ParseChord does for 'chordString'.

Fixes #128

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

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit febda6c into main Sep 27, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the fix/parse-phrase-empty-128 branch September 27, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ParsePhrase("") throws "Phrase must contain at least one chord (Parameter 'sequence')" from its own empty-input guard

1 participant