Skip to content

fix(cli): Explain set-commits --commit repositories that Sentry doesn't have - #1902

Merged
betegon merged 1 commit into
mainfrom
cli/set-commits-commit-repo
Nov 4, 2026
Merged

betegon merged 1 commit into
mainfrom
cli/set-commits-commit-repo

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Part 6 of the set-commits stack, on #1900.

About 73% of CLI-2SK is release set-commits --commit owner/repo@sha naming a repository the org doesn't have. Many of these come from Vercel builds, where the bundler plugin passes the repository name. Sentry matches names exactly (Release.set_refs, name__in) and answers with {"refs":["Invalid repository names: ..."]}. The CLI only showed "API request failed: 400 Bad Request".

The CLI now looks the repository up and says which case applies:

  • Same repository under another name (case, GitLab display names): the error names the Sentry name and gives a ready-to-run --commit command.
  • The org has no repositories: the error links the source code integrations page and suggests sentry integration list.
  • The repository isn't added: the error lists up to three similar names, sentry repo list, and the repository settings link.

The lookups are best-effort. If they fail, the error still links the repository settings. Other errors pass through unchanged.

The error is a ValidationError with field commit.repository. The next PR stops reporting it to Sentry. The release docs now say that commits need a repository in Sentry.

via bete.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
sentry-local Ready Ready Preview Nov 4, 2026 10:01am UTC

Request Review

@sentry-junior
sentry-junior Bot added this pull request to stack #1867 November 3, 2026 20:02
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 3, 2026
@betegon
betegon force-pushed the cli/set-commits-commit-repo branch from 1bc5724 to a477d55 Compare November 3, 2026 20:58
@betegon
betegon self-requested a review November 3, 2026 20:59
@betegon
betegon force-pushed the cli/set-commits-commit-repo branch from a477d55 to 72d63d0 Compare November 3, 2026 21:21
Base automatically changed from cli/set-commits-no-repos to main November 4, 2026 09:27
betegon pushed a commit that referenced this pull request Nov 4, 2026
…inds no repos (#1900)

Part 5 of the set-commits stack. #1866 has merged, so this is now on
`main`. Splits CLI-2SK into one PR per fix.

When the org has no repositories in Sentry, `release set-commits --auto`
only said "No repository integrations configured for this organization."
That's about 27% of CLI-2SK. Nothing on the command line can fix it, so
the error now says where to go next:

- It links the org's source code integrations page
(`/settings/integrations/?category=source%20code%20management`).
- It suggests `sentry integration list <org>/`.
- It suggests `--local` when run inside a git checkout.

The CLI can't install integrations (`sentry integration` only has `list`
and `delete`, and GitHub needs a browser install), so the error sends
people to the Sentry UI.

It stays an `ApiError` with the same message and 404 status, so default
mode still falls back to local history and error reporting still
silences it.

The rest of CLI-2SK is in #1902 (`--commit` with a repository Sentry
doesn't have) and #1903 (stop reporting that one as a CLI error).

## Before / after

The real CLI, run from source, against a local mock of the Sentry API
for an org `acme` with no repositories. Before is `8eba364a` (the old
base, before this change). After is `207c4e8d`, the current head on
`main`.

**Git checkout, `origin` = `github.com/acme/web`**

Before:
```console
$ sentry release set-commits acme/1.0.0 --auto
Error: No repository integrations configured for this organization.
  Endpoint: organizations/acme/releases/1.0.0/
```

After:
```console
$ sentry release set-commits acme/1.0.0 --auto
Error: No repository integrations configured for this organization.
  Endpoint: organizations/acme/repos/
  Connect GitHub, GitLab, Bitbucket, or Azure DevOps to Sentry and add the repository: https://acme.sentry.io/settings/integrations/?category=source%20code%20management

Try:
  sentry integration list acme/
  sentry release set-commits acme/1.0.0 --local
```

**No `.git`, repository from CI variables (`GITHUB_REPOSITORY`,
`GITHUB_SHA`)**

Before:
```console
$ sentry release set-commits acme/1.0.0 --auto
[info] [api.releases] No 'origin' git remote found. Using acme/web@4f2c9e1b7a3d from GITHUB_REPOSITORY/GITHUB_SHA.
Error: No repository integrations configured for this organization.
  Endpoint: organizations/acme/releases/1.0.0/
```

After (no `--local`, since there's no git history to read):
```console
$ sentry release set-commits acme/1.0.0 --auto
[info] [api.releases] No 'origin' git remote found. Using acme/web@4f2c9e1b7a3d from GITHUB_REPOSITORY/GITHUB_SHA.
Error: No repository integrations configured for this organization.
  Endpoint: organizations/acme/repos/
  Connect GitHub, GitLab, Bitbucket, or Azure DevOps to Sentry and add the repository: https://acme.sentry.io/settings/integrations/?category=source%20code%20management

Try:
  sentry integration list acme/
```

Both exit with code 30, before and after.

**Unchanged: default mode still falls back to local history** (same
output before and after):
```console
$ sentry release set-commits acme/1.0.0
[warn] [release.set-commits] Could not auto-discover commits (no repository integration). Falling back to local git history.
Commits Set: 1.0.0
```

**The suggested command runs:**
```console
$ sentry integration list acme/
No integrations found in organization 'acme'.
```

## The integrations link

- **Sentry's UI uses the same link.** The onboarding "link a repository"
task (`static/app/components/onboardingWizard/taskConfig.tsx`) and the
stack trace "add integration" banner (`addIntegrationBanner.tsx`) both
link `/settings/${org}/integrations/` with `query: {category: 'source
code management'}`.
- **The filter shows the right integrations.** The directory reads
`location.query.category` (`integrationListDirectory.tsx`).
`getCategories` in `integrationUtil.tsx` maps the `commits` feature to
`source code management`. The integrations with
`IntegrationFeatures.COMMITS` are GitHub, GitHub Enterprise, GitLab,
Bitbucket, Bitbucket Server, Azure DevOps (`vsts`), and Perforce.
- **The page exists.**
`https://sentry.sentry.io/settings/integrations/?category=source%20code%20management`
returns a 302 to the org login (`/auth/login/sentry/`). A settings path
that doesn't exist redirects to `/settings/sentry/` instead.
- **Self-hosted** uses `/settings/<org>/integrations/`, which is covered
by `sentry-urls.property.test.ts`.

<!-- junior-request-attribution:start -->
via **bete**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0C615WFS9G%3A1793734411.837769 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0C615WFS9G%3A1793734411.837769)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0C615WFS9G%3A1793734411.837769/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
@betegon
betegon force-pushed the cli/set-commits-commit-repo branch from 72d63d0 to 339c2ed Compare November 4, 2026 09:27
@sentry-junior
sentry-junior Bot force-pushed the cli/set-commits-commit-repo branch from 339c2ed to 9253290 Compare November 4, 2026 09:29
…'t have

About 73% of CLI-2SK is `release set-commits --commit owner/repo@sha`
naming a repository the org doesn't have. Sentry matches the name
exactly (`Release.set_refs`) and answers with
`{"refs":["Invalid repository names: ..."]}`, which the CLI showed as
"API request failed: 400 Bad Request".

The CLI now looks the repository up and says which case applies:

- The org has it under another name (case, GitLab display names): the
  error names it and gives a ready-to-run `--commit` command.
- The org has no repositories: the error links the source code
  integrations page and suggests `sentry integration list`.
- The repository isn't added: the error lists up to three similar
  names, `sentry repo list`, and the repository settings link.

The error is a ValidationError with field "commit.repository". The
release docs now say commits need a repository in Sentry.

Co-Authored-By: Miguel Betegon <miguel.betegon@sentry.io>
@sentry-junior
sentry-junior Bot force-pushed the cli/set-commits-commit-repo branch from 9253290 to 49bc712 Compare November 4, 2026 09:59
@betegon
betegon merged commit 08fac06 into main Nov 4, 2026
27 checks passed
@betegon
betegon deleted the cli/set-commits-commit-repo branch November 4, 2026 17:34
betegon added a commit that referenced this pull request Nov 4, 2026
… differs in form (#1948)

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**

```console
$ 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**

```console
$ 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:

```console
$ 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:

```console
$ 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:

```console
$ 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.

<!-- junior-request-attribution:start -->
via @betegon.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0C615WFS9G%3A1793734411.837769 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0C615WFS9G%3A1793734411.837769)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0C615WFS9G%3A1793734411.837769/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Miguel Betegon <28983162+betegon@users.noreply.github.com>
Co-authored-by: bete <miguel.betegon@sentry.io>

This branch was successfully deployed

1 active deployment
Preview — 49bc7121 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