Skip to content

fix(arg-parsing): handle space-separated event IDs (CLI-1HT)#1268

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

fix(arg-parsing): handle space-separated event IDs (CLI-1HT)#1268
sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix/cli-1ht-whitespace-split

Conversation

@sentry

@sentry sentry Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Previously, the splitNewlineArg function in src/lib/arg-parsing.ts only 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 a ValidationError: Invalid Event ID: contains a space. because the entire string was treated as one ID.

This change modifies splitNewlineArg to 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 constant WHITESPACE_RE.

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

github-actions Bot commented Jul 17, 2026

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-21 20:40 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/lib/arg-parsing.ts Outdated
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

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

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

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

@sentry sentry Bot changed the title fix(arg-parsing): split arguments by all whitespace fix(arg-parsing): handle space-separated event IDs (CLI-1HT) Jul 21, 2026
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: medium PR risk score: medium labels Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants