feat(init): resolve projects and improve existing setups - #1374
Conversation
41c51ff to
3263729
Compare
3263729 to
2458762
Compare
2458762 to
504e0cb
Compare
504e0cb to
a794d55
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
5036a86 to
9648c5d
Compare
| (item) => item.kind === "config" && item.sdkConfig | ||
| ); | ||
| const installed = | ||
| runtimeInitialization.length > 0 || hasSdkConfig || Boolean(dsn); |
There was a problem hiding this comment.
Per-app DSN scan escapes the target
High Severity
detectSentrySetup treats the first repo-wide DSN as proof that the selected target is installed. detectAllDsnOccurrences walks to findProjectRoot and scans that tree, so a sibling app's DSN can mark this package installed and send init into the improve/reuse path for the wrong project.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 9648c5d. Configure here.
| ) { | ||
| return; | ||
| } | ||
| return { selectedApp: items[0] }; |
There was a problem hiding this comment.
Unattended single-target setup is rejected
Medium Severity
When --yes sees exactly one target whose sentrySetup is detected, autoSelectTarget returns nothing and handleSelect throws the multi-target “use --app” error. Unattended init then fails on a single app instead of selecting it and continuing through the existing-setup path.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 9648c5d. Configure here.
| } catch (fallbackError) { | ||
| if (isMemberCreationDisabled403(fallbackError)) { | ||
| throw buildTeamAdminAuthorizationError(orgSlug, team.slug); | ||
| } |
There was a problem hiding this comment.
Org policy error becomes scope error
Medium Severity
If an auto-selected team create fails and the org-scoped fallback returns member-project-creation disabled, that policy 403 is rewritten as a missing team:admin authorization error. Users get the wrong recovery path, including a useless OAuth refresh.
Reviewed by Cursor Bugbot for commit 9648c5d. Configure here.
| return explicit; | ||
| } | ||
| assertImprovementSupported(setup, options); | ||
| return markExistingSetupForImprovement(explicit, setup); |
There was a problem hiding this comment.
Explicit setup cannot fall back safely
Medium Severity
An explicit project that matches the local setup always calls assertImprovementSupported. If the setup service is old or the health check did not advertise improve-existing-setup, init throws instead of offering another project the way the implicit detected-setup path does.
Reviewed by Cursor Bugbot for commit 9648c5d. Configure here.
9648c5d to
0e98f09
Compare
| opts.existingProject.projectSlug === slug | ||
| ? opts.existingProject | ||
| : await tryGetExistingProjectData(opts.org, slug).catch(() => null); | ||
| const existingProject = await tryGetExistingProjectData(opts.org, slug); |
There was a problem hiding this comment.
Project lookup errors abort init
Medium Severity
resolveExistingProjectChoice and findAvailableProjectSlug now call tryGetExistingProjectData without handling non-404 failures. A 403 or 5xx during existence checks fails the whole wizard instead of treating the lookup as “not reusable” or “name taken.”
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 0e98f09. Configure here.
0e98f09 to
8282394
Compare
| const shown = eligibleTeams.slice(0, 10); | ||
| const remaining = eligibleTeams.length - shown.length; | ||
| throw new ContextError("Team", `${options.usageHint} --team <team-slug>`, [ | ||
| `You are a Team Admin of ${eligibleTeams.length} teams in '${orgSlug}'. Choose one explicitly with --team.`, | ||
| ...shown.map((team) => `Available: ${team.slug}`), | ||
| ...(remaining > 0 ? [`...and ${remaining} more`] : []), | ||
| ]); |
There was a problem hiding this comment.
Bug: In non-interactive mode, resolveEligibleTeam throws an error if multiple eligible teams exist, instead of falling back to the intended new-project-creation flow.
Severity: HIGH
Suggested Fix
Modify resolveEligibleTeam to return { kind: "create" } instead of throwing an error when it encounters multiple eligible teams and no chooseTeam callback is provided. This will allow the control flow in resolveOrCreateTeam to correctly fall back to resolveNewTeam as intended in non-interactive scenarios.
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: packages/cli/src/lib/resolve-team.ts#L229-L235
Potential issue: When running a command in non-interactive mode, such as `sentry init
--yes`, the `resolveOrCreateTeam` function is called. If the user is an admin of
multiple teams, the `resolveEligibleTeam` function throws a `ContextError`, requiring
the user to specify a `--team` flag. This prevents the intended fallback behavior, which
is to proceed to `resolveNewTeam` to create a new project. The current implementation
contradicts the expected behavior of defaulting to new project creation when an
unambiguous choice cannot be made in a non-interactive session.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
There are 7 total unresolved issues (including 5 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8282394. Configure here.
| ...envResult.dsns, | ||
| ...(envDsn ? [envDsn] : []), | ||
| ]; | ||
| } |
There was a problem hiding this comment.
Per-app DSN scan escapes target
High Severity
detectSentrySetup treats the first repo-wide DSN as proof the selected target is already installed. detectAllDsnOccurrences walks to the git root and scans the whole tree, so a sibling package DSN can mark an uninitialized app as installed and send init into the improve-existing flow for the wrong project.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 8282394. Configure here.
| throw new WizardCancelledError(); | ||
| } | ||
| if (choice === "create") { | ||
| return { project: undefined }; |
There was a problem hiding this comment.
Failed health check blocks existing setups
Medium Severity
A failed or timed-out readiness check still starts the wizard but reports improveExistingSetup: false. --yes and matching explicit-project runs then hit assertImprovementSupported and abort, even though readiness itself only warned that the service might retry.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 8282394. Configure here.
8282394 to
709a2d8
Compare


Summary
sentry initresolve the organization early, then resolve the project from the concrete selected application instead of the monorepo rootsentry initandsentry project create, including complete team pagination, Team Admin choices, personal-team creation, and accurate organization-policy errorsOAuth support
Merged PR #1373 adds
team:adminto the standard OAuth scope set and supports one bounded refresh for older eligible interactive grants. Unattended, JSON, dry-run, and environment-token execution do not start OAuth.Validation
pnpm --filter sentry typecheckCI=1, including repeated transition coveragegit diff --checkCloses #1375.
Terminal-height overflow remains separate in #1376.