Repository navigation
ci(openapi-diff): Compare API schemas with the PR's merge-base - #130541
Merged
Merged
Conversation
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]>
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 |
Co-Authored-By: BYK <[email protected]>
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 | |---|---| |  |  | **Create a Custom Inbound Filter** (experimental, with a body) | Before | After | |---|---| |  |  | **List Your Organizations** | Before | After | |---|---| |  |  | ## 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
approved these changes
Nov 14, 2026
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>
8 of 39 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
openapi-diffcompared every backend PR with getsentry/sentry-api-schemamain, which is the latest master and not where the PR branched off, so its diff also showed unrelated master changes. Itsjson-diffstep 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_docsfilter. 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/apiintostatic/packages/api, which gives master a second baseline source besides sentry-api-schema: theapi@release assets.What changes
Baselines come from the PR's merge-base.
openapi.ymlnow uploadstests/apidocs/openapi-derefed.jsonandrpc_method_schema.jsonfrom each master build as anapi-schemasartifact, kept for 30 days.scripts/openapi-diff.sh baselinegets 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:api@GitHub release, picked by listing releases, sincereleases/latestis sentry's calver release;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
changelogjob writes anoasdiff changelog --format markdownto 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-breakingjob runsoasdiff breaking --fail-on WARNon the RPC schema, so nothing upstream can skip it. Control and cell silos deploy separately, and the new requiredapi-clientcheck (feat(api): Move the @sentry/api package into static/packages/api #130472) doesn't cover RPC.One build. The
buildjob still builds the spec and RPC schema once, withsetup-sentry. The two compare jobs only download its artifact and run the oasdiff image, so CI cost stays about the same.make diff-api-docsruns the same script: the merge-base baseline, then the changelog. It needs gh and docker. That replacesapi-docs/openapi-diff.tsand itsjson-diffdependency, so the lockfile only loses thejson-diffsubtree.A new
make build-rpc-schemawrites.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.ymlandMakefile.build-rpc-schematarget, and point theapi-schemasupload atstatic/packages/api/spec/or.artifacts/rpc_method_schema.json. The baseline script finds both files by name inside the artifact, so their paths don't matter.Verification
--shell=sh --enable=check-extra-masked-returns) is clean. actionlint reports nothing new; its only finding is the existingubuntu-26.04-armlabel. knip is clean.api-schemasartifact exists yet and there's noapi@release, so it fell back to sentry-api-schemamain(15.8 MB spec plus RPC schema) in 18 s.api@release exists: it uses the release;rpc-breakingon identical schemas exits 0, and on a schema with a removed method it prints::errorand exits 1.Co-Authored-By: BYK [email protected]
via @BYK.
--
View Session in Sentry