# Sentry: upload fails, release not found

## The error

A `sentry-cli sourcemaps upload --release [version]` (or similar) fails because the release does not exist in Sentry yet.

## Why it happens

Upload commands attach artifacts to a release. If nothing created that release, there is nothing to attach to. Sentry does auto-create a release when the first event arrives with that identifier, but your CI upload runs before any event exists, so at upload time the release is absent.

## The fix: create, then upload

```
sentry-cli releases -o [your org] new -p [your project] [version]
sentry-cli releases -o [your org] -p [your project] set-commits [version] --auto
sentry-cli sourcemaps upload --release [version] [maps dir]
```

Note the scoping: org on the `releases` command, project on the subcommand. Get this backwards and the release is created on the wrong project, which produces the same not-found error on the next step.

## The identifier must match everywhere

The `[version]` in the CLI, the `release` in SDK init (or `SENTRY_RELEASE`), and the deployed code must be byte-identical. Usual culprits: a `v` prefix in one place, trailing whitespace from CI variables, or the SDK inferring the git SHA while CI passes a tag name. Pick one scheme (`service@version` recommended) and generate it once per pipeline run.

## Verify

After the pipeline, open the Releases page and confirm the version shows with commits and the uploaded artifacts. Auto-created releases (from events alone) work for grouping but lack commits and deploy markers, so the explicit create step is worth keeping.