Skip to content

fix(arg-parsing): normalize spaces in slugs and trim whitespace in issue IDs (CLI-14M, CLI-16M)#757

Merged
BYK merged 3 commits intomainfrom
byk/fix-slug-space-normalization
Apr 15, 2026
Merged

fix(arg-parsing): normalize spaces in slugs and trim whitespace in issue IDs (CLI-14M, CLI-16M)#757
BYK merged 3 commits intomainfrom
byk/fix-slug-space-normalization

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Apr 15, 2026

Summary

  • Extend normalizeSlug() to convert spaces → dashes with lowercasing and consecutive dash collapsing, matching how Sentry generates slugs from display names (e.g., "My Project""my-project")
  • Reorder parsing flow so normalization runs before validateResourceId() — spaces become dashes before the forbidden-character check can reject them
  • Add .trim() to parseIssueArg() and parseSlashSeparatedArg() to strip trailing whitespace/newlines from AI agent inputs

Motivation

Two related ValidationError issues from the input validation layer:

  • CLI-14M: Invalid project slug: contains a space. — User passed a display name like "My Project" instead of slug "my-project"
  • CLI-16M: Invalid issue identifier: contains a newline. — AI agent (Claude) passed an issue ID with a trailing \n

The validation itself is correct (agent hallucination hardening), but the parsing layer should normalize recoverable inputs before validation — just like it already normalizes underscores → dashes.

Key Design Decisions

  • Lowercase only when spaces are present"my_project" stays "my-project" (preserves casing for backward compat), but "My Project""my-project" since spaces imply a display name
  • validateResourceId() unchanged — Still rejects spaces as defense-in-depth for any code path that skips normalizeSlug
  • No space normalization in issue IDsparseIssueArg only trims, since issue identifiers like "CLI-G5" should never have internal spaces silently converted
  • Reason-aware warning messages"spaces" → "use lowercase with dashes, not spaces"; "both" → "not spaces or underscores"

…sue IDs (CLI-14M, CLI-16M)

Extend normalizeSlug() to convert spaces to dashes (with lowercasing and
dash collapsing), matching how Sentry generates slugs from display names.
Reorder parsing to normalize before validating so spaces become dashes
before validateResourceId() rejects them.

Add .trim() to parseIssueArg() and parseSlashSeparatedArg() to handle
trailing newlines from AI agents.

Fixes CLI-14M (space in project slug) and CLI-16M (newline in issue ID).
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (arg-parsing) Normalize spaces in slugs and trim whitespace in issue IDs (CLI-14M, CLI-16M) by BYK in #757

Internal Changes 🔧

  • Regenerate docs by github-actions[bot] in 34bf056d

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

PR Preview Action v1.8.1

QR code for preview link

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

Built to branch gh-pages at 2026-04-15 14:33 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/lib/arg-parsing.ts Outdated
@BYK BYK marked this pull request as ready for review April 15, 2026 14:22
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

Codecov Results 📊

134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 97.47%. Project has 1627 uncovered lines.
✅ Project coverage is 95.33%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/lib/arg-parsing.ts 97.47% ⚠️ 2 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    95.33%    95.33%        —%
==========================================
  Files          234       234         —
  Lines        34792     34839       +47
  Branches         0         0         —
==========================================
+ Hits         33167     33212       +45
- Misses        1625      1627        +2
- Partials         0         0         —

Generated by Codecov Action

Use [_ ]+ to replace runs of underscores/spaces with a single dash
in one pass instead of two separate replace calls.
@BYK BYK merged commit a6d00ce into main Apr 15, 2026
26 checks passed
@BYK BYK deleted the byk/fix-slug-space-normalization branch April 15, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant