fix(issue): accept multi-line issue identifiers by keeping first line (CLI-1G1)#1148
Merged
Conversation
…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.
Contributor
|
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 5112 uncovered lines. 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 -1Generated by Codecov Action |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sentry issue view <id>(and every command that resolves an issue) threw acryptic
ValidationError: Invalid issue identifier: contains a newline.whenthe identifier argument contained an internal newline. This is
CLI-1G1 — 288 events / 116
users, ongoing on the latest release (0.38.0).
Root cause
parseIssueArgran onlyarg.trim(), which strips leading and trailingwhitespace 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.:
sentry issue view "$(...)"CLI-G\nthe auth-token errorThe surviving newline reached
validateResourceId→rejectControlChars,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.
sentry api(CLI-FR), which rejoins wrapped URLs, identifiers areatomic tokens — joining lines would produce garbage, so we keep only the
first line.
\ndoes not affect project display names with spaces(fix(arg-parsing): allow project display names with spaces in org/project argument #1116): newlines are control characters that are rejected regardless.
Test plan
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 passedvitest run test/lib/arg-parsing.property.test.ts test/lib/security/url-arg-poison.test.ts→ 40 passedbiome checkclean on changed filesFixes CLI-1G1