fix(arg-parsing): split arguments by all whitespace#1268
Conversation
|
| export function splitNewlineArg(arg: string): string[] { | ||
| return arg | ||
| .split("\n") | ||
| .split(/\s+/) |
There was a problem hiding this comment.
Bug: The change to split arguments on any whitespace (/\s+/) in splitNewlineArg will incorrectly break up project display names containing spaces, like "org/My Project".
Severity: HIGH
Suggested Fix
The fix should be more targeted to only apply to the arguments that are expected to be lists (like event IDs), while preserving the original behavior for arguments that could be project display names. This might involve making the splitting behavior conditional or applying it at a different stage of parsing, after project arguments have already been identified and handled. For example, only apply the whitespace split within the event view command's argument handling, not globally in splitNewlineArg.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/lib/arg-parsing.ts#L1247
Potential issue: The function `splitNewlineArg` was changed to split arguments on any
whitespace (`/\s+/`) to support space-separated IDs. However, this introduces a
regression. The CLI supports project display names with spaces (e.g., `"org/My
Project"`), and has logic to handle them as a single argument. When such a display name
is passed as a single string, which is a common scenario for programmatic callers like
AI agents, the new logic will incorrectly split it into multiple arguments (e.g.,
`["org/My", "Project"]`). This breaks downstream parsing logic which expects a single
project argument, causing command failures.
Also affects:
src/commands/event/view.ts:179
Did we get this right? 👍 / 👎 to inform future reviews.
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 5479 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.67% 81.67% —%
==========================================
Files 426 426 —
Lines 29896 29896 —
Branches 19420 19420 —
==========================================
+ Hits 24416 24417 +1
- Misses 5480 5479 -1
- Partials 2035 2034 -1Generated by Codecov Action |
This PR addresses CLI-1HT, where users (especially AI agents) encountered
ValidationError: Invalid Event ID: contains a space.when providing multiple event IDs as a single, space-separated argument.The root cause was that the
splitNewlineArgutility function, intended to expand multiple IDs from a single string, only split on newline characters (\n). This meant that space-separated IDs were treated as a single, invalid ID.This fix modifies
splitNewlineArginsrc/lib/arg-parsing.tsto split on all whitespace (/\s+/) instead of just newlines. This ensures that event IDs provided with spaces, tabs, or newlines are correctly parsed into individual arguments, preventing validation errors.Fixes CLI-1HT
Comment
@sentry <feedback>on this PR to have Autofix iterate on the changes.