Skip to content

feat(init): add --team flag to relay team selection to project creation#403

Merged
MathurAditya724 merged 2 commits intomainfrom
fix/init-teams
Mar 12, 2026
Merged

feat(init): add --team flag to relay team selection to project creation#403
MathurAditya724 merged 2 commits intomainfrom
fix/init-teams

Conversation

@MathurAditya724
Copy link
Member

Summary

  • Adds --team / -t flag to sentry init so users on multiple teams can specify which team to create the project under
  • Threads the team slug through WizardOptionshandleLocalOpcreateSentryProjectresolveOrCreateTeam
  • Without this, sentry init fails with a ContextError when users belong to multiple teams, since there was no way to pass the --team flag that project create already supports

Usage

sentry init --team my-team
sentry init -t my-team

When users belong to multiple teams, the create-project step during
init would fail with a ContextError asking them to specify --team.
The init command had no way to accept that flag. This adds --team/-t
to sentry init, threading it through WizardOptions to
resolveOrCreateTeam so team resolution is skipped when explicitly set.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 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 ✨

Init

  • Add --team flag to relay team selection to project creation by MathurAditya724 in #403
  • Enforce canonical feature display order by betegon in #388
  • Accept multiple delimiter formats for --features flag by betegon in #386
  • Add git safety checks before wizard modifies files by betegon in #379
  • Add experimental warning before wizard runs by betegon in #378
  • Add init command for guided Sentry project setup by betegon in #283

Issue List

  • Auto-compact when table exceeds terminal height by BYK in #395
  • Redesign table to match Sentry web UI by BYK in #372

Other

  • Add --dry-run flag to mutating commands by BYK in #387
  • Return-based output with OutputConfig on buildCommand by BYK in #380
  • Add --fields flag for context-window-friendly JSON output by BYK in #373
  • Magic @ selectors (@latest, @most_frequent) for issue commands by BYK in #371
  • Input hardening against agent hallucinations by BYK in #370
  • Add response caching for read-only API calls by BYK in #330

Bug Fixes 🐛

Init

  • Remove implementation detail from help text by betegon in #385
  • Truncate uncommitted file list to first 5 entries by MathurAditya724 in #381

Other

  • (api) Convert --data to query params for GET requests by BYK in #383
  • (docs) Remove double borders and fix column alignment on landing page tables by betegon in #369
  • Add trace ID validation to trace view + UUID dash-stripping by BYK in #375

Internal Changes 🔧

Init

  • Remove --force flag by betegon in #377
  • Remove dead determine-pm step label by betegon in #374

Other

  • Migrate non-streaming commands to CommandOutput with markdown rendering by BYK in #398
  • Convert Tier 2-3 commands to return-based output and consola by BYK in #394
  • Convert remaining Tier 1 commands to return-based output by BYK in #382
  • Converge Tier 1 commands to writeOutput helper by BYK in #376

Other

  • Minify JSON on read and pretty-print on write in init local ops by MathurAditya724 in #396

🤖 This preview updates automatically when you update the PR.

@MathurAditya724 MathurAditya724 marked this pull request as ready for review March 12, 2026 11:29
@MathurAditya724 MathurAditya724 requested a review from betegon March 12, 2026 11:29
@github-actions
Copy link
Contributor

Codecov Results 📊

104 passed | Total: 104 | 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 100.00%. Project has 917 uncovered lines.
❌ Project coverage is 95.49%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    95.50%    95.49%    -0.01%
==========================================
  Files          142       142         —
  Lines        20343     20352        +9
  Branches         0         0         —
==========================================
+ Hits         19427     19435        +8
- Misses         916       917        +1
- Partials         0         0         —

Generated by Codecov Action

Comment on lines 81 to 87
yes: flags.yes,
dryRun: flags["dry-run"],
features: featuresList,
team: flags.team,
});
},
});
Copy link

Choose a reason for hiding this comment

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

Bug: The sentry init command with the --team flag lacks validation for non-existent team slugs, resulting in a generic API error instead of a helpful message.
Severity: MEDIUM

Suggested Fix

Implement the same sophisticated error handling found in the project create command within the init command's workflow. Specifically, when a 404 error is received from the createProject API call, check if the cause was an invalid team slug and, if so, provide a user-friendly error message that lists the available teams for the organization.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/commands/init.ts#L81-L87

Potential issue: When the `sentry init` command is used with the new `--team` flag, the
provided team slug is not validated. If a user supplies a slug for a team that does not
exist, the CLI will proceed to call the project creation API endpoint. This API call
will fail with a 404 error, but the error handling in the `init` command is generic.
Unlike the `sentry project create` command, which has specific logic to detect a
non-existent team and provide a helpful message listing available teams, the `init`
command will only show the user a raw, unhelpful API error message.

Did we get this right? 👍 / 👎 to inform future reviews.

@MathurAditya724 MathurAditya724 enabled auto-merge (squash) March 12, 2026 11:31
@MathurAditya724 MathurAditya724 merged commit 809ef5f into main Mar 12, 2026
21 checks passed
@MathurAditya724 MathurAditya724 deleted the fix/init-teams branch March 12, 2026 11:32
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