Skip to content

fix(issue): accept multi-line issue identifiers by keeping first line (CLI-1G1)#1148

Merged
BYK merged 1 commit into
mainfrom
byk/fix/issue-arg-multiline
Jun 26, 2026
Merged

fix(issue): accept multi-line issue identifiers by keeping first line (CLI-1G1)#1148
BYK merged 1 commit into
mainfrom
byk/fix/issue-arg-multiline

Conversation

@BYK

@BYK BYK commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

sentry issue view <id> (and every command that resolves an issue) threw a
cryptic ValidationError: Invalid issue identifier: contains a newline. when
the identifier argument contained an internal newline. This is
CLI-1G1288 events / 116
users
, ongoing on the latest release (0.38.0).

Root cause

parseIssueArg ran only arg.trim(), which strips leading and trailing
whitespace but leaves internal newlines intact. Since trim already removes
outer newlines, the only way to hit the newline check is multi-line content,
e.g.:

  • command substitution that captured extra output: sentry issue view "$(...)"
  • an identifier with an appended note: CLI-G\nthe auth-token error
  • several newline-separated IDs pasted as one argument

The surviving newline reached validateResourceIdrejectControlChars,
producing the cryptic error.

Fix

Take the first non-blank line instead of bare-trimming. An issue
identifier is always a single line, so the first non-blank line is the intended
value.

Test plan

  • Added a multi-line and whitespace input (CLI-1G1) describe block covering:
    trailing newline (CLI-16M regression), leading blank lines, appended note,
    multiple newline-separated IDs, CRLF endings, and all-blank input.
  • vitest run test/lib/arg-parsing.test.ts → 186 passed
  • vitest run test/lib/arg-parsing.property.test.ts test/lib/security/url-arg-poison.test.ts → 40 passed
  • biome check clean on changed files

Fixes CLI-1G1

…CLI-1G1)

parseIssueArg only ran .trim() on the raw argument, which strips leading
and trailing whitespace but leaves internal newlines intact. When an
identifier arrived with an embedded newline — command substitution that
captured extra output, an appended note, or several newline-separated
IDs — the surviving newline reached validateResourceId and threw a
cryptic "Invalid issue identifier: contains a newline" ValidationError
(CLI-1G1, 116+ affected users on 0.38.0).

An issue identifier is always a single line, so take the first non-blank
line instead. Unlike `sentry api` (CLI-FR), which rejoins wrapped URLs,
identifiers are atomic tokens — joining lines would produce garbage.
Splitting on newlines does not affect project display names with spaces
(#1116) because newlines are control chars that are rejected regardless.
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Jun 26, 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-1148/

Built to branch gh-pages at 2026-06-26 19:13 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

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

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.52%    81.53%    +0.01%
==========================================
  Files          397       397         —
  Lines        27679     27682        +3
  Branches     17966     17968        +2
==========================================
+ Hits         22566     22570        +4
- Misses        5113      5112        -1
- Partials      1868      1867        -1

Generated by Codecov Action

@BYK BYK merged commit cac7768 into main Jun 26, 2026
28 checks passed
@BYK BYK deleted the byk/fix/issue-arg-multiline branch June 26, 2026 19:23
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.

1 participant