fix(arg-parsing): handle space-separated event IDs (CLI-1HT)#1268
fix(arg-parsing): handle space-separated event IDs (CLI-1HT)#1268sentry[bot] wants to merge 2 commits into
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 5478 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.69% 81.69% —%
==========================================
Files 426 426 —
Lines 29909 29910 +1
Branches 19433 19433 —
==========================================
+ Hits 24431 24432 +1
- Misses 5478 5478 —
- Partials 2035 2035 —Generated by Codecov Action |
Previously, the
splitNewlineArgfunction insrc/lib/arg-parsing.tsonly split strings by newline characters (\n). This caused issues when AI agents (and potentially users) provided multiple event IDs separated by spaces as a single argument, leading to aValidationError: Invalid Event ID: contains a space.because the entire string was treated as one ID.This change modifies
splitNewlineArgto split on any whitespace (/\s+/), ensuring that event IDs separated by spaces, tabs, or newlines are correctly parsed into individual arguments. To comply with linting rules (lint/performance/useTopLevelRegex), the regex literal was moved to a top-level constantWHITESPACE_RE.Fixes CLI-1HT
Comment
@sentry <feedback>on this PR to have Autofix iterate on the changes.