Skip to content

fix(project create): auto-correct dot-separated platform to hyphens#336

Merged
BYK merged 1 commit intomainfrom
fix/platform-dot-separator
Mar 4, 2026
Merged

fix(project create): auto-correct dot-separated platform to hyphens#336
BYK merged 1 commit intomainfrom
fix/platform-dot-separator

Conversation

@BYK
Copy link
Member

@BYK BYK commented Mar 4, 2026

Problem

Users pass dot-separated platform identifiers like javascript.nextjs (matching Sentry's SDK guide URLs like sentry.io/for/javascript.nextjs) but Sentry's API expects hyphen-separated format (javascript-nextjs). This results in a confusing CliError: Invalid platform 'javascript.nextjs' error.

Sentry issue: https://sentry.sentry.io/issues/7308899722/

Solution

Following the established CLI pattern of auto-correcting common user mistakes with stderr warnings (same approach as normalizeFields() in api.ts), this PR adds a normalizePlatform() function that:

  1. Detects dots in the platform string (dots are never valid in platform identifiers)
  2. Replaces them with hyphens
  3. Warns on stderr so the user knows what happened

This is safe to auto-correct because:

  • The input containing dots is already invalid
  • The correction is unambiguous (dots → hyphens)
  • The warning is emitted on stderr, not stdout

Changes

  • src/commands/project/create.ts: Added normalizePlatform() function and applied it before the platform is sent to the API
  • test/commands/project/create.test.ts: Added 3 tests for platform normalization

Before

$ sentry project create my-org/my-app javascript.nextjs
Error: Invalid platform 'javascript.nextjs'.

After

$ sentry project create my-org/my-app javascript.nextjs
warning: platform 'javascript.nextjs' uses '.' instead of '-' — interpreting as 'javascript-nextjs'

Created project 'my-app' in my-org
...

Fixes CLI-AT

Users commonly copy platform identifiers from Sentry's SDK guide URLs
which use dots (e.g., javascript.nextjs) when the API expects hyphens
(javascript-nextjs). Since dots are never valid in platform identifiers,
this is safe to auto-correct.

Following the established pattern from normalizeFields() in api.ts:
auto-correct the invalid input and warn on stderr.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 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).


New Features ✨

Trace

Other

  • (api) Add --data/-d flag and auto-detect JSON body in fields by BYK in #320
  • (formatters) Render all terminal output as markdown by BYK in #297
  • (install) Add Sentry error telemetry to install script by BYK in #334
  • (issue-list) Global limit with fair distribution, compound cursor, and richer progress by BYK in #306
  • (log-list) Add --trace flag to filter logs by trace ID by BYK in #329
  • (project) Add project create command by betegon in #237
  • (upgrade) Add binary delta patching via TRDIFF10/bsdiff by BYK in #327

Bug Fixes 🐛

Api

  • Use numeric project ID to avoid "not actively selected" error by betegon in #312
  • Use limit param for issues endpoint page size by BYK in #309
  • Auto-correct ':' to '=' in --field values with a warning by BYK in #302

Formatters

  • Expand streaming table to fill terminal width by betegon in #314
  • Fix HTML entities and escaped underscores in table output by betegon in #313

Setup

  • Suppress agent skills and welcome messages on upgrade by BYK in #328
  • Suppress shell completion messages on upgrade by BYK in #326

Other

  • (ci) Generate JUnit XML to silence codecov-action warnings by BYK in #300
  • (install) Fix nightly digest extraction on macOS by BYK in #331
  • (nightly) Push to GHCR from artifacts dir so layer titles are bare filenames by BYK in #301
  • (project create) Auto-correct dot-separated platform to hyphens by BYK in #336
  • (region) Resolve DSN org prefix at resolution layer by BYK in #316
  • (test) Handle 0/-0 in getComparator anti-symmetry property test by BYK in #308
  • (trace-logs) Timestamp_precise is a number, not a string by BYK in #323

Internal Changes 🔧

Api

  • Upgrade @sentry/api to 0.21.0, remove raw HTTP pagination workarounds by BYK in #321
  • Wire listIssuesPaginated through @sentry/api SDK for type safety by BYK in #310

Other

  • (craft) Add sentry-release-registry target by BYK in #325

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Codecov Results 📊

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

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +3
Passed Tests 📈 +3
Failed Tests
Skipped Tests

All tests are passing successfully.

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

Files with missing lines (1)
File Patch % Lines
create.ts 95.86% ⚠️ 11 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    82.42%    82.43%    +0.01%
==========================================
  Files          126       126         —
  Lines        17782     17792       +10
  Branches         0         0         —
==========================================
+ Hits         14656     14666       +10
- Misses        3126      3126         —
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK merged commit c8aa617 into main Mar 4, 2026
20 checks passed
@BYK BYK deleted the fix/platform-dot-separator branch March 4, 2026 14:34
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