Skip to content

fix(cli): Use Sentry's repository name when set-commits --commit only differs in form - #1948

Merged
betegon merged 3 commits into
mainfrom
cli/set-commits-correct-repo
Nov 4, 2026
Merged

betegon merged 3 commits into
mainfrom
cli/set-commits-correct-repo

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Part of the CLI-2SK work. The branch is based on main after #1902. #1903 was closed and is not part of this change.

Sentry matches --commit repository names exactly (Release.set_refs, name__in). A name that refers to the same repository but is written differently, for example in a different case, fails with Invalid repository names. On Vercel production builds, @sentry/bundler-plugins passes VERCEL_GIT_REPO_OWNER/VERCEL_GIT_REPO_SLUG as-is, which is one way to end up with such a name.

Change. When the server rejects --commit refs as invalid repository names, the CLI now looks up each rejected name with the same matching --auto uses (findSentryRepository: case-insensitive name, URL path, GitLab display names). If every rejected name matches a Sentry repository, the CLI retries once with Sentry's names and prints a warning for each name it replaced. If any rejected name has no match, or the lookup fails, the command fails with #1902's error and next steps, unchanged. The commit range (PREV..SHA) the caller passed is kept.

Before / after

The CLI was run from source against a local stand-in for the Sentry API that rejects names the way Release.set_refs does. "Before" is main at 08fac06c (#1902), "after" is this branch.

Same repository, different case (org acme has acme/web)

Before

$ sentry release set-commits acme/1.0.0 --commit 'Acme/Web@abc1234..def5678'
Error: Sentry organization 'acme' has no repository named 'Acme/Web'. It has 'acme/web'. --commit needs the repository name exactly as Sentry shows it.

Try:
  sentry release set-commits acme/1.0.0 --commit 'acme/web@abc1234..def5678'
# exit 21

After

$ sentry release set-commits acme/1.0.0 --commit 'Acme/Web@abc1234..def5678'
[warn] [api.releases] Sentry organization 'acme' has no repository named 'Acme/Web'. Using 'acme/web', the same repository in Sentry.
Commits Set: 1.0.0
━━━━━━━━━━━━━━━━━━

╭─────────┬───────╮
│ Version │ 1.0.0 │
│ Commits │ 3     │
╰─────────┴───────╯
# exit 0

The retry sends acme/web with the same abc1234..def5678 range.

One name matches, another has no match (org acme has only acme/web)

Before and after are the same. No retry runs, and no "Using ..." warning is printed:

$ sentry release set-commits acme/1.0.0 --commit 'Acme/Web@abc1234..def5678,Acme/Api@def5678'
Error: Sentry organization 'acme' has no repository named 'Acme/Web'. It has 'acme/web'. --commit needs the repository name exactly as Sentry shows it.

Try:
  sentry release set-commits acme/1.0.0 --commit 'acme/web@abc1234..def5678'
# exit 21

Org has no repositories

Before and after are the same:

$ sentry release set-commits acme/1.0.0 --commit 'Acme/Web@abc1234..def5678'
Error: Sentry organization 'acme' has no repository named 'Acme/Web'. It has no repositories yet, so it cannot associate commits.

Try:
  sentry integration list acme/

Note: Connect GitHub, GitLab, Bitbucket, or Azure DevOps to Sentry and add the repository: https://acme.sentry.io/settings/integrations/?category=source%20code%20management
# exit 21

Repository not in Sentry, similar names exist (org acme has acme/website, acme/web-app, acme/api)

Before and after are the same:

$ sentry release set-commits acme/1.0.0 --commit 'Acme/Web@abc1234..def5678'
Error: Sentry organization 'acme' has no repository named 'Acme/Web'. It has similarly named repositories: acme/website, acme/web-app.

Try:
  sentry release set-commits acme/1.0.0 --commit 'acme/website@abc1234..def5678'
  sentry release set-commits acme/1.0.0 --commit 'acme/web-app@abc1234..def5678'
  sentry repo list acme/

Note: Add the repository to Sentry through your source code integration: https://acme.sentry.io/settings/repos/
# exit 21

Why the CLI and not only the plugin

The fix applies to every --commit caller: the bundler plugin, CI scripts and people. The plugin keeps passing Vercel's previous deployment SHA, so the range doesn't change.

Tests

  • correctRefRepositories: case-only correction (with its warning), no match, a later name with no match (no warning, no retry), other errors (no lookup), lookup failure.
  • set-commits --commit retries with the corrected refs.
  • The release, error-reporting and URL suites pass (284 tests), and pnpm run lint passes. I did not run the full suite.

via @betegon.

--

View Session [Sentry]

@sentry-junior
sentry-junior Bot added this pull request to stack #1867 November 4, 2026 16:26
@vercel

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 4, 2026 5:46pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 4, 2026

@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 ecefc07. Configure here.

Comment thread packages/cli/src/lib/api/releases.ts Resolved
sentry-junior Bot and others added 3 commits November 4, 2026 17:45
… differs in form

Sentry matches --commit repository names exactly, so a name that differs
from Sentry's only in case or form (for example the VERCEL_GIT_REPO_OWNER/
VERCEL_GIT_REPO_SLUG that @sentry/bundler-plugins passes) fails with
'Invalid repository names'. When every rejected name matches a Sentry
repository the same way --auto matches, retry once with Sentry's names and
warn. Otherwise keep explaining the error.

Co-Authored-By: Miguel Betegon <28983162+betegon@users.noreply.github.com>
Co-Authored-By: bete <miguel.betegon@sentry.io>
correctRefRepositories logged a warning for each rejected name it could
replace, then gave up when a later name had no match. Those warnings
said Sentry's name was used even though no retry ran. Collect the
replacements first and warn only once every rejected name matched.

Co-Authored-By: Miguel Betegon <28983162+betegon@users.noreply.github.com>
Co-Authored-By: bete <miguel.betegon@sentry.io>
The repository quality lint (no-async-catch-callback) rejects async
callbacks passed to .catch(). Await the call in try/catch instead so
the retry and error path stay in async stack traces.

Co-Authored-By: Miguel Betegon <28983162+betegon@users.noreply.github.com>
Co-Authored-By: bete <miguel.betegon@sentry.io>
@sentry-junior
sentry-junior Bot force-pushed the cli/set-commits-correct-repo branch from 24bb50f to d17f673 Compare November 4, 2026 17:46
@betegon
betegon self-requested a review November 4, 2026 17:46
@sentry-junior
sentry-junior Bot removed this pull request from stack #1867 November 4, 2026 17:49
@sentry-junior
sentry-junior Bot changed the base branch from cli/set-commits-silence-repo to main November 4, 2026 17:49
@betegon
betegon merged commit 69647d4 into main Nov 4, 2026
28 of 29 checks passed
@betegon
betegon deleted the cli/set-commits-correct-repo branch November 4, 2026 19:12

This branch was previously deployed

1 inactive deployment
Preview — d17f6733 Deployed Nov 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant