Skip to content

fix(project): create multiple projects; clear error on space-crammed names#1191

Open
betegon wants to merge 10 commits into
mainfrom
fix/project-create-multiple
Open

fix(project): create multiple projects; clear error on space-crammed names#1191
betegon wants to merge 10 commits into
mainfrom
fix/project-create-multiple

Conversation

@betegon

@betegon betegon commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

sentry project create now creates multiple projects at once, and turns the cryptic 400 from space-crammed names into actionable guidance.

This fixes the production issue behind Sentry CLI-1YY (https://sentry.sentry.io/issues/7529054898/): AI agents were calling sentry project create "web api worker ..." — all the names crammed into one quoted argument — and the API rejected the resulting name with a bare HTTP 400.

What changed

  • Names are variadic (matching the issue merge convention): sentry project create web api worker node creates three projects. The trailing positional is the platform, or pass --platform/-p. All names share one org.
  • Backward compatible: sentry project create my-app node still works exactly as before.
  • Actionable error: when a single name contains spaces and the API rejects it, the error now points to the variadic form (sentry project create web api worker node) instead of surfacing a raw 400.

Commas are intentionally not used — spaces are ambiguous (Sentry display names may contain them), so we rely on separate arguments, which is also how every other multi-value command in the CLI works.

Test plan

  • pnpm vitest run test/commands/project/create.test.ts — 44 pass (3 new: multiple names, --platform flag, crammed-name 400 guidance).
  • Dry-run verified: single (backward compat), multiple (3 previews), --platform flag, and missing-platform error.

…names

Names are now variadic (like issue merge): `sentry project create web api
worker node` creates three projects; the trailing arg is the platform, or
use --platform. `create <name> <platform>` still works. When a single name
has spaces and the API 400s, the error points to the variadic form instead
of a cryptic HTTP 400. Fixes the cause of Sentry CLI-1YY.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Jul 3, 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-1191/

Built to branch gh-pages at 2026-07-03 16:19 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 92.41%. Project has 5318 uncovered lines.
✅ Project coverage is 81.8%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/commands/project/create.ts 92.41% ⚠️ 6 Missing and 8 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.78%    81.80%    +0.02%
==========================================
  Files          423       423         —
  Lines        29194     29222       +28
  Branches     18980     18997       +17
==========================================
+ Hits         23874     23904       +30
- Misses        5320      5318        -2
- Partials      1968      1973        +5

Generated by Codecov Action

Match the sibling error-builders (buildPlatformError, isPlatformError)
which annotate their return types.

Co-authored-by: Cursor <cursoragent@cursor.com>
@betegon betegon marked this pull request as ready for review July 3, 2026 14:31
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Jul 3, 2026
Comment thread src/commands/project/create.ts
Pair `project create` with the CLI's multi-value flag convention
(`--features a,b`, set-commits `--path a,b`, `auth login --scope a,b`):
each positional name may now also be comma-separated, so
`create web,api,worker node` == `create web api worker node`. Commas
are never valid in a slug, so this is unambiguous and prevents an agent
comma-habit (`a,b,c`) from silently creating one `a-b-c` project.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/commands/project/create.ts Outdated
betegon and others added 2 commits July 3, 2026 16:50
Positionals are space-separated variadic (also comma-tolerant); optional
flags are comma-separated. Splits the rule by argument type so agents pick
the right shape.

Co-authored-by: Cursor <cursoragent@cursor.com>
USAGE_HINT now reflects variadic names + platform ([<org>/]<name...>
<platform>). The crammed-name 400 message no longer asserts names "can't
span multiple words" (the 400 may be a length issue), instead framing
both the multi-project and single-project fixes.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/commands/project/create.ts
resolvePlatformAndNames passed only args[0] to buildPlatformError, so a
bad platform with multiple names (`create proj1 proj2 bad`) hinted just
`proj1`. Echo the full name list per branch so the usage example matches
what was typed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: medium PR risk score: medium labels Jul 3, 2026
Comment thread src/commands/project/create.ts
In multi-project create, the auto-create team slug is now pinned to the
first project for the whole batch. A real run already creates one team on
the first project and reuses it; dry-run previews now agree instead of
showing a divergent "would create team" per project in an empty org.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3ea97b8. Configure here.

Comment thread src/commands/project/create.ts
Comment thread src/commands/project/create.ts
betegon and others added 2 commits July 3, 2026 17:42
createProjectWithAutoTeamFallback rethrew 400s unchanged, so a crammed
multi-word name that reached the org-scoped fallback (after a team-scoped
403) still surfaced the raw API error. Apply the same actionable guidance
there.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Extract projectExistsError() so the 409 "already exists" message + view
  hint live in one place (was duplicated across the team and org-scoped
  fallback paths).
- Pass a field to the multi-org ValidationError so error-reporting doesn't
  collapse it into the unfielded fingerprint.
- Use USAGE_HINT for the missing-name error instead of a stale hardcoded
  usage string.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant