Skip to content

ci(openapi-diff): Compare API schemas with the PR's merge-base - #130541

Merged
BYK merged 2 commits into
masterfrom
ci/openapi-diff-merge-base
Nov 14, 2026
Merged

BYK merged 2 commits into
masterfrom
ci/openapi-diff-merge-base

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

openapi-diff compared every backend PR with getsentry/sentry-api-schema main, which is the latest master and not where the PR branched off, so its diff also showed unrelated master changes. Its json-diff step exits 1 on any difference, so the job failed on every PR that changes the spec. That's why develop-docs calls the failure expected, and also why the RPC breaking-change step after it was skipped on exactly those PRs.

In the 100 runs I sampled, 69 hit the api_docs filter. 27 failed at json-diff, and the RPC check was skipped in all 27. The other 42 ran the RPC check and passed. #130472 moves @sentry/api into static/packages/api, which gives master a second baseline source besides sentry-api-schema: the api@ release assets.

What changes

  • Baselines come from the PR's merge-base. openapi.yml now uploads tests/apidocs/openapi-derefed.json and rpc_method_schema.json from each master build as an api-schemas artifact, kept for 30 days. scripts/openapi-diff.sh baseline gets the merge-base from the compare API and walks back up to 30 master commits to the closest one with that artifact. Every commit that can change the schemas uploads one. Fallbacks, in order:

    1. the newest api@ GitHub release, picked by listing releases, since releases/latest is sentry's calver release;
    2. sentry-api-schema main, for as long as it still receives the spec.

    The job summary says which baseline it used. Each source writes to a scratch directory, so a source that fails halfway leaves nothing behind.

  • The public spec diff is a changelog. The changelog job writes an oasdiff changelog --format markdown to the job summary, capped below GitHub's 1 MiB limit, and never fails. A missing baseline or an oasdiff error becomes a note in the summary.

  • The RPC check runs in its own job. The rpc-breaking job runs oasdiff breaking --fail-on WARN on the RPC schema, so nothing upstream can skip it. Control and cell silos deploy separately, and the new required api-client check (feat(api): Move the @sentry/api package into static/packages/api #130472) doesn't cover RPC.

  • One build. The build job still builds the spec and RPC schema once, with setup-sentry. The two compare jobs only download its artifact and run the oasdiff image, so CI cost stays about the same.

  • make diff-api-docs runs the same script: the merge-base baseline, then the changelog. It needs gh and docker. That replaces api-docs/openapi-diff.ts and its json-diff dependency, so the lockfile only loses the json-diff subtree.

  • A new make build-rpc-schema writes .artifacts/rpc_method_schema.json. It's the same target feat(api): Move the @sentry/api package into static/packages/api #130472 adds.

  • A shellcheck pre-commit hook (--shell=sh --enable=check-extra-masked-returns) covers the new script.

The develop-docs text that says this check is expected to fail is updated in getsentry/sentry-docs#20679, which already rewrites that section.

Interaction with #130472

This PR is off master and doesn't depend on #130472, but the two touch neighboring lines in openapi.yml and Makefile.

Verification

  • shellcheck (--shell=sh --enable=check-extra-masked-returns) is clean. actionlint reports nothing new; its only finding is the existing ubuntu-26.04-arm label. knip is clean.
  • Baseline lookup, run for real under dash with feat(api): Move the @sentry/api package into static/packages/api #130472's base and head SHAs: no api-schemas artifact exists yet and there's no api@ release, so it fell back to sentry-api-schema main (15.8 MB spec plus RPC schema) in 18 s.
  • Baseline lookup, run with a stubbed gh:
    • the artifact is on the second commit back: it's used;
    • the artifact is missing a file and an api@ release exists: it uses the release;
    • every source fails: it exits 1 and leaves no partial files behind;
    • gh fails: it exits 1.
  • Changelog and RPC check, run with the real oasdiff v1.33.0 binary:
    • a real spec diff gives an 8.8 KB Markdown changelog;
    • identical specs give "No changes detected";
    • a missing baseline or a bad JSON spec gives a note, and every one of these exits 0;
    • rpc-breaking on identical schemas exits 0, and on a schema with a removed method it prints ::error and exits 1.
  • No UI change.

Co-Authored-By: BYK [email protected]

via @BYK.

--

View Session in Sentry

The openapi-diff job compared each PR with getsentry/sentry-api-schema
main, so it showed unrelated master changes. json-diff exited 1 on any
spec change, so the job failed on every API PR and skipped the RPC
breaking-change check exactly then.

- The openapi workflow uploads the master spec and RPC schema as an
  api-schemas artifact. PRs take their baseline from the artifact for
  their merge-base, falling back to the newest api@ release and then to
  sentry-api-schema main.
- The public spec diff is an oasdiff changelog in the job summary and
  never fails.
- The RPC oasdiff breaking check runs in its own job, so it always runs.
- make diff-api-docs uses the same script, replacing the json-diff
  script and its dependency.

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested review from a team as code owners November 9, 2026 22:53
@github-actions github-actions Bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

BYK added a commit to getsentry/sentry-docs that referenced this pull request Nov 13, 2026
The API reference now comes from the `@sentry/api` version this repo
pins (`2.3.0`), through its `./docs` export
(getsentry/sentry-api-schema#150). It no longer fetches
`openapi-derefed.json` from a pinned getsentry/sentry-api-schema commit.
The rendered pages don't change.

## Changes

- **`src/build/resolveOpenAPI.ts`** reads `{tags, operations}` from
`@sentry/api/docs` and maps them to the `APICategory`/`API` shapes the
pages already use.
- `OPENAPI_LOCAL_PATH` still works in development. It runs a local `make
build-api-docs` spec through the package's `extractDocs()`, so previews
take the same path as production.
  - `src/build/open-api/types.ts` is gone; the package types replace it.
- Optional query parameters now carry `required: false` instead of no
key. The pages check `!!param.required`, so they render the same.
- **`scripts/tsconfig.json`** maps `@sentry/api/docs` to `dist/docs.js`
for the Algolia script. `tsx` resolves through Node's CJS resolver, and
the export only has an `import` condition.
- **Bump workflow:** `bump-api-schema-sha.yml` is now **Bump
@sentry/api**. It keeps its file name, so existing dispatches still
reach it.
- It runs hourly and on `workflow_dispatch`, with a concurrency group so
the two can't push the same branch.
- `scripts/bump-sentry-api.sh` (POSIX `sh`) reads the latest version
from npm, pins it exactly in `package.json` and the lockfile, then opens
and merges the PR with the same app token as before. A pre-commit hook
runs shellcheck on it.
  - Dependabot here only does security updates, so it doesn't fit.
- **`pnpm-workspace.yaml`** only holds settings (no `packages` list). It
puts `@sentry/api` in `minimumReleaseAgeExclude`, so the hourly bump can
still pin a release minutes after it ships once pnpm applies a
release-age default. It does nothing on the current `[email protected]`: the
lockfile, dependency tree, `package.json` pnpm settings and root `pnpm
add` behave as before.
- **`develop-docs/backend/api/public.mdx`:** the build process section
describes the new flow, and the `openapi-diff` text matches
getsentry/sentry#130541: a changelog that never fails, plus a separate
RPC breaking-change job. Hold that part until that PR merges.

## Screenshots

These `next dev` screenshots are 1400px wide. Before is the current
reader on the same spec through `OPENAPI_LOCAL_PATH`; after is this PR
reading `@sentry/api/docs`. The images are pixel-identical except for
the Next.js dev badge, so two pairs have the same URL.

**Create a New Team**

| Before | After |
|---|---|
|
![before](https://junior-prod.sentry.dev/public/artifacts/707914ce-aa28-4ed5-a9a7-f6a6b7cc9a1e.png)
|
![after](https://junior-prod.sentry.dev/public/artifacts/3b1116af-bf1b-49ea-b6f7-4c94b9e53976.png)
|

**Create a Custom Inbound Filter** (experimental, with a body)

| Before | After |
|---|---|
|
![before](https://junior-prod.sentry.dev/public/artifacts/682fdbb5-f4bc-4c61-be92-4ded51d63568.png)
|
![after](https://junior-prod.sentry.dev/public/artifacts/682fdbb5-f4bc-4c61-be92-4ded51d63568.png)
|

**List Your Organizations**

| Before | After |
|---|---|
|
![before](https://junior-prod.sentry.dev/public/artifacts/69f1d6af-e058-40cb-b457-bb5a14d90af3.png)
|
![after](https://junior-prod.sentry.dev/public/artifacts/69f1d6af-e058-40cb-b457-bb5a14d90af3.png)
|

## After merging

sentry-api-schema's "Cascade to sentry-docs" dispatch is no longer
needed.

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

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A69da19b385017e68b7f9eace56e9477f -->

--

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

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

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
@BYK
BYK merged commit e99eb0e into master Nov 14, 2026
82 checks passed
@BYK
BYK deleted the ci/openapi-diff-merge-base branch November 14, 2026 00:58
BYK added a commit that referenced this pull request Nov 14, 2026
…0472)

Moves `@sentry/api`, the generated TypeScript client for Sentry's public
API, from getsentry/sentry-api-schema to `static/packages/api`. It
builds from `tests/apidocs/openapi-derefed.json`, the spec this
repository generates. The npm name stays `@sentry/api`, so
getsentry/toolkit, sentry-docs and other consumers don't change. This PR
replaces the pre-merge check from #130450, which was closed.

This PR doesn't publish anything. Releases from here stay off until a
person cuts the first `api@` tag (see the cutover section).

## Package

- The sources match getsentry/sentry-api-schema `main` at 2.3.1,
including the `@sentry/api/docs` API reference export
(getsentry/sentry-api-schema#150), the `listPage` `per_page` fix
(getsentry/sentry-api-schema#149) and `insufficient_scope` handling on
`ApiPermissionError` (getsentry/sentry-api-schema#146).
- One deliberate difference from sentry-api-schema `main`: the generated
`buildUrl` trims trailing slashes from the base URL before appending
`/api/0` (`withApiBasePath` in `lib/api-client/api-base-url.ts`), so
`https://sentry.io/` no longer requests `https://sentry.io//api/0`.
Published 2.x versions keep that bug; the fix ships with the first
`api@` release from here.
- `package.json` is at 2.3.1, the latest npm version. Craft bumps from
it while there is no `api@` tag, so the first release from here lands
after sentry-api-schema's.
- Differences from sentry-api-schema, all because of where the package
now lives:
- TypeScript 6 through the repo's `@typescript/typescript6` alias, and
zod 4.6.7, the version `static/app`, gsApp, gsAdmin and scraps already
pin. The other dev tools are pinned to exact versions, and oxlint
matches the repo's 1.90.0.
- The build reads the spec files through `lib/spec-files.mjs` and
collects them under `spec/`.
- `source-analysis` uses a path-parameter pattern that can't backtrack
on runs of `{`, for a CodeQL alert the move raised.
- The scripts are `test:vitest` and `lint:js`, not `test` and `lint`.
The repo's `test-ci` and `test-all` pass Jest flags to every workspace's
`test` script, and the repo's `lint:js` runs each workspace's `lint:js`.

## Spec files on GitHub releases

Each `[email protected]` GitHub release gets the files that version was built
from as assets. The pack job adds them to the release artifact; craft's
github target attaches every file in it, and its npm target publishes
only the tarball:

- `openapi-derefed.json`, the dereferenced OpenAPI spec.
- `rpc_method_schema.json`, for the openapi-diff/RPC check. It comes
from a new `make build-rpc-schema` target.
- `api_ownership_stats_dont_modify.json`, which `make build-api-docs`
still generates. No known consumer reads it; it is kept for ad-hoc and
future use.

For example:
`https://github.com/getsentry/sentry/releases/download/[email protected]/openapi-derefed.json`.
The npm package doesn't include them.

## CI: `api client` is a required check

The new `api-client` job in `backend.yml` builds, typechecks, lints and
tests the client against the PR's own spec. It is part of
`backend-required-check`. A spec change that broke the client once
stalled releases for 2 days with nothing catching it before merge; this
check catches that class of change.

- It reuses the spec from the `api-docs` job (shared as a workflow
artifact), so the spec isn't built twice.
- Both jobs run only when the new `api_client` filter matches: the
existing `api_docs` paths plus `static/packages/api/**`. On other PRs
both jobs are skipped, and `backend-required-check` counts skipped jobs
as passing.

## Releases

- **Pack:** `package-pack.yml` sets up the Python env for `api`, then
builds the spec, the RPC schema and the package before `pnpm pack`.
- **Release on change:** a `release-api-package` job in `openapi.yml`
runs after the master spec build whenever the spec or the package might
have changed. It runs
`.github/workflows/scripts/api-package-release-preflight.sh`, then
`craft prepare` with `getsentry/publish`. The preflight skips the
release when:
- there is no `api@` tag yet, so the job stays inert until the first
release is cut by hand;
- an `api/release/*` branch is still pending. When that release merges
back, its own run releases whatever landed in the meantime;
  - HEAD predates the newest `api@` tag;
- the spec, the RPC schema and the package are unchanged since the last
release. It compares the files against the last release's assets.
- **Version bump:** a spec change is a minor release, as in
sentry-api-schema. A package change uses craft's automatic bump. An
RPC-schema-only change is a patch. An ownership-stats-only change
doesn't release; the file refreshes with the next release.
- **Concurrency:** releases share a concurrency group with
`cancel-in-progress: false`, so a burst of merges produces one release.
- There is no cron. Manual releases go through the Release workflow,
which gets a `static/packages/api` option.
- **sentry-docs:** `bump-sentry-docs.yml` runs on each published `api@`
release. `.craft.yml` lists the npm target before github for
`static/packages/*`, so the version is already on npm when the release
is published (the same order applies to icons, scraps and search-syntax,
and nothing in them needs the tag before the npm publish). It dispatches
sentry-docs' `bump-api-schema-sha.yml` by file name with the existing
`SENTRY_API_SCHEMA_UPDATER` app. sentry-docs' bump reads the version
from npm, so it works the same after the move.
- The mirror push to getsentry/sentry-api-schema still runs, on the same
`api_client` filter, and the release doesn't wait for it.

## Cutover (in this order)

1. Merge #130541 and getsentry/eng-pipes#1116, which retires the `apis`
command. #130541 falls back to sentry-api-schema `main` until an `api@`
release exists.
2. Merge this PR.
3. In getsentry/publish `auto-approve-repos.txt`, replace the
`getsentry/sentry-api-schema` line with this repo's
`static/packages/api` entry.
4. Disable sentry-api-schema's Release workflow and its sentry-docs
dispatch workflow (getsentry/sentry-api-schema#155), so only one repo
publishes.
5. Cut the first `api@` release by hand: run the Release workflow with
workspace `static/packages/api`. Check that the version it picks is
above sentry-api-schema's last npm release. From then on, `openapi.yml`
releases on change.
6. Remove the openapi-diff fallback, the mirror push in `openapi.yml`,
and the sentry-api-schema links in the getsentry/toolkit docs,
getsentry/skills `document-api-endpoint` and devinfra-mcp
`docs/sentry/ci.md`.
7. Archive getsentry/sentry-api-schema. Its copies of the
`SENTRY_API_SCHEMA_UPDATER_*` credentials can go with it.

`static/packages/api/` is owned by @getsentry/owners-api and
@getsentry/ocpo in CODEOWNERS.

This PR touches `static/` as well as backend CI files. The package is a
standalone npm package and isn't part of either deploy, so splitting it
wouldn't change what gets deployed.

No UI change.

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

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A69da19b385017e68b7f9eace56e9477f -->

--

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

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

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
@sentry-junior sentry-junior Bot mentioned this pull request Nov 14, 2026
8 of 39 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant