Skip to content

fix(arg-parsing): split arguments by all whitespace#1268

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/cli-1ht-whitespace-split
Open

fix(arg-parsing): split arguments by all whitespace#1268
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/cli-1ht-whitespace-split

Conversation

@sentry

@sentry sentry Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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 splitNewlineArg utility 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 splitNewlineArg in src/lib/arg-parsing.ts to 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.

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Jul 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1268/

Built to branch gh-pages at 2026-07-17 23:11 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/lib/arg-parsing.ts
export function splitNewlineArg(arg: string): string[] {
return arg
.split("\n")
.split(/\s+/)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 5479 uncovered lines.
✅ Project coverage is 81.67%. Comparing base (base) to head (head).

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        -1

Generated by Codecov Action

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

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants