Skip to content

feat(project): add project create command#237

Open
betegon wants to merge 12 commits intomainfrom
feat/project-create
Open

feat(project): add project create command#237
betegon wants to merge 12 commits intomainfrom
feat/project-create

Conversation

@betegon
Copy link
Member

@betegon betegon commented Feb 12, 2026

Summary

Adds sentry project create <name> <platform> — the first write command in the CLI. Follows gh repo create conventions with org/name syntax, auto-detection of org and team, and actionable errors at every step.

Changes

  • New SentryTeam Zod schema and type
  • listTeams() and createProject() API functions with region-aware routing (TEAM_ENDPOINT_REGEX)
  • project create command with two required positionals, --team/-t flag, and --json output
  • Team auto-selection when org has exactly one team; lists available teams otherwise
  • Org fallback: on 404 from bad auto-detected org, shows user's actual organizations
  • DSN fetched after creation (best-effort) so the user can start sending events immediately
  • 19 tests covering happy path, missing args, team resolution, conflict handling, and JSON output

Test Plan

  • bun test test/commands/project/create.test.ts — 19 pass, 0 fail
  • bun run typecheck — clean
  • bun run lint — clean
  • Manually tested against live API: create with auto-team, explicit team, bad team, 409 conflict, missing args, JSON mode

Add team schema/type and two new API functions needed for project
creation. Also adds TEAM_ENDPOINT_REGEX so /teams/{org}/... endpoints
route to the correct region.
Adds `sentry project create <name> <platform> [--team] [--json]`.

Supports org/name syntax (like gh repo create owner/repo), auto-detects
org from config/DSN, and auto-selects team when the org has exactly one.
Fetches the DSN after creation so users can start sending events
immediately. All error paths are actionable — wrong org lists your orgs,
wrong team lists available teams, 409 links to the existing project.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 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 ✨

  • (formatters) Add Seer fixability score to issue list and detail views by betegon in #234
  • (project) Add project create command by betegon in #237
  • (team) Add team list command by betegon in #238

Bug Fixes 🐛

Telemetry

  • Use SDK session integration instead of manual management by BYK in #232
  • Correct runtime context for Bun binary by BYK in #231

Other

  • (setup) Use correct auth command in install welcome message by betegon in #241
  • (tests) Centralize test config dir lifecycle to prevent env var pollution by BYK in #242

🤖 This preview updates automatically when you update the PR.

github-actions bot and others added 4 commits February 12, 2026 20:14
When the API returns 400 for an invalid platform string, show the same
helpful platform list instead of a raw JSON error body.
Replace the confusing 'Or: - Available platforms:' pattern with a
cleaner 'Usage: ... Available platforms:' layout. Applies to both
missing platform and invalid platform errors.
- tryGetPrimaryDsn() → api-client.ts (was duplicated in view + create)
- resolveTeam() → resolve-team.ts (reusable for future team-dependent commands)
- parseOrgPrefixedArg() → arg-parsing.ts (reusable org/name parsing)
- writeKeyValue() for aligned key-value output in create.ts
- project/view.ts now uses shared tryGetPrimaryDsn instead of local copy
@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

Codecov Results 📊

✅ Patch coverage is 93.53%. Project has 4101 uncovered lines.
✅ Project coverage is 69.71%. Comparing base (base) to head (head).

Files with missing lines (71)
File Patch % Lines
human.ts 58.29% ⚠️ 395 Missing
resolve-target.ts 20.26% ⚠️ 366 Missing
list.ts 14.39% ⚠️ 345 Missing
api-client.ts 64.94% ⚠️ 251 Missing
list.ts 23.47% ⚠️ 212 Missing
oauth.ts 30.68% ⚠️ 183 Missing
list.ts 21.96% ⚠️ 167 Missing
plan.ts 19.37% ⚠️ 154 Missing
resolver.ts 3.23% ⚠️ 120 Missing
help.ts 19.85% ⚠️ 109 Missing
upgrade.ts 57.71% ⚠️ 107 Missing
view.ts 36.48% ⚠️ 101 Missing
interactive-login.ts 9.17% ⚠️ 99 Missing
errors.ts 5.94% ⚠️ 95 Missing
view.ts 25.81% ⚠️ 92 Missing
view.ts 39.44% ⚠️ 86 Missing
clipboard.ts 4.49% ⚠️ 85 Missing
status.ts 24.07% ⚠️ 82 Missing
migration.ts 47.44% ⚠️ 82 Missing
list.ts 27.18% ⚠️ 75 Missing
browser.ts 4.11% ⚠️ 70 Missing
login.ts 33.33% ⚠️ 64 Missing
span-tree.ts 5.00% ⚠️ 57 Missing
explain.ts 33.33% ⚠️ 56 Missing
api.ts 89.80% ⚠️ 47 Missing
upgrade.ts 66.91% ⚠️ 46 Missing
telemetry.ts 84.72% ⚠️ 46 Missing
seer.ts 75.54% ⚠️ 45 Missing
schema.ts 89.56% ⚠️ 40 Missing
refresh.ts 40.63% ⚠️ 38 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 53.23% ⚠️ 29 Missing
utils.ts 88.94% ⚠️ 25 Missing
view.ts 61.54% ⚠️ 25 Missing
view.ts 87.86% ⚠️ 25 Missing
detector.ts 90.10% ⚠️ 20 Missing
binary.ts 88.67% ⚠️ 17 Missing
list.ts 91.16% ⚠️ 16 Missing
list.ts 90.70% ⚠️ 16 Missing
code-scanner.ts 95.00% ⚠️ 16 Missing
help.ts 57.14% ⚠️ 15 Missing
arg-parsing.ts 91.37% ⚠️ 12 Missing
dsn-cache.ts 94.62% ⚠️ 12 Missing
logout.ts 56.00% ⚠️ 11 Missing
token.ts 52.17% ⚠️ 11 Missing
fix.ts 83.61% ⚠️ 10 Missing
qrcode.ts 33.33% ⚠️ 10 Missing
fs-utils.ts 57.14% ⚠️ 9 Missing
view.ts 94.70% ⚠️ 7 Missing
project-root.ts 97.73% ⚠️ 7 Missing
version-check.ts 91.76% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
create.ts 97.48% ⚠️ 6 Missing
auth.ts 95.52% ⚠️ 6 Missing
shell.ts 96.23% ⚠️ 6 Missing
app.ts 93.90% ⚠️ 5 Missing
setup.ts 97.84% ⚠️ 4 Missing
list.ts 97.33% ⚠️ 4 Missing
index.ts 95.96% ⚠️ 4 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
project-root-cache.ts 96.92% ⚠️ 2 Missing
output.ts 89.47% ⚠️ 2 Missing
alias.ts 99.42% ⚠️ 1 Missing
completions.ts 99.37% ⚠️ 1 Missing
env-file.ts 99.19% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
colors.ts 98.21% ⚠️ 1 Missing
trace.ts 99.16% ⚠️ 1 Missing
resolve-team.ts 98.55% ⚠️ 1 Missing
helpers.ts 97.62% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    69.08%    69.71%    +0.63%
==========================================
  Files          107       109        +2
  Lines        13195     13537      +342
  Branches         0         0         —
==========================================
+ Hits          9115      9436      +321
- Misses        4080      4101       +21
- Partials         0         0         —

Generated by Codecov Action

# Conflicts:
#	src/lib/api-client.ts
The /teams/{org}/{team}/projects/ endpoint returns 404 for both a bad
org and a bad team. Previously we always blamed the team, which was
misleading when --team was explicit and the org was auto-detected wrong.

Now on 404 we call listTeams(orgSlug) to check:
- If it succeeds → team is wrong, show available teams
- If it fails → org is wrong, show user's actual organizations

Only adds an API call on the error path, never on the happy path.
The view command hint on 409 used the raw name ('My Cool App') instead
of the expected slug ('my-cool-app'), pointing to a non-existent target.
Copy link

@cursor cursor bot left a comment

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.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

handleCreateProject404 was treating any listTeams failure as proof that
the org doesn't exist. Now it checks the status code: only 404 triggers
'Organization not found'. Other failures (403, 5xx, network) get a
generic message that doesn't misdiagnose the root cause.
Same class of bug as the previous fix in handleCreateProject404:
resolveTeam was routing all ApiErrors from listTeams into the 'org not
found' path. Now only 404 triggers that diagnosis. Other failures
(403, 5xx) get a generic message that doesn't misdiagnose the cause.
@betegon betegon requested a review from BYK February 13, 2026 19:46
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