Skip to content

ref(api): Read the API base path from @sentry/api - #2233

Merged
BYK merged 2 commits into
mainfrom
feat/api-base-path-export
Nov 13, 2026
Merged

BYK merged 2 commits into
mainfrom
feat/api-base-path-export

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Depends on: @sentry/api 2.0.0, which is published (getsentry/sentry-api-schema#148). This is the last step of the chain sentry-api-schema#148 → sentry-docs#20787 → sentry#131065 → this PR.

Sentry's OpenAPI spec is moving /api/0 out of every path and into its server URL. @sentry/api 2.0 reads the base path from that URL, exports it as API_BASE_PATH, and makes operation paths relative. This PR drops toolkit's private /api/0 copies and uses the export instead, so the version number lives only in the spec.

Before:

const API_PREFIX = "/api/0";                          // cli/src/commands/api.ts
this.apiPrefix = `${protocol}://${host}/api/0`;       // mcp-core api-client
path: operation.path,                                 // "/api/0/organizations/" in 1.x

After:

import { API_BASE_PATH } from "@sentry/api/client";
this.apiPrefix = `${protocol}://${host}${API_BASE_PATH}`;
path: `${API_BASE_PATH}${operation.path}`,            // still "/api/0/organizations/"
  • CLI endpoint index: it keeps full request paths, so sentry schema and sentry api still show and accept /api/0/....
  • Requests: CLI raw requests now pass relative URLs to prepareRequest.
  • Unchanged on purpose: user-facing help text and examples still say /api/0.
  • Breaking: only the @sentry/api 1.x → 2.0.0 bump. CLI and MCP behavior doesn't change, so no toolkit major is needed.

#2229 (stacked on #1807): on 2.0 it needs two changes:

  • replace its local API_PREFIX = "/api/0" in error-reporting.ts with API_BASE_PATH;
  • build api-path-templates.json from `${API_BASE_PATH}${op.path}`, because op.path is now relative.

Checks:

  • pnpm run tsc and pnpm run lint pass.
  • mcp-core vitest: 2301 passed.
  • The CLI api, schema, sentry-client, error-reporting, issue-links and script tests: 82 files, 1685 passed.
  • pnpm install --frozen-lockfile passes with the minimumReleaseAgeExclude entry moved from 1.83.0 to 2.0.0.

--

View Session [Sentry]

sentry-junior Bot and others added 2 commits November 13, 2026 12:58
@sentry/api 2.0 reads the API base path (/api/0) from the server URL in
Sentry's OpenAPI spec, exports it as API_BASE_PATH, and makes operation
paths and raw request URLs relative to it. Use the export instead of
private /api/0 copies, pass relative URLs to prepareRequest, and keep the
CLI's endpoint index in full request paths by prefixing the base path.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
2.0.0 exports API_BASE_PATH and reads the base path from the spec's
server URL, which this branch depends on.
@vercel

vercel Bot commented Nov 13, 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 13, 2026 2:03pm UTC

Request Review

@BYK
BYK enabled auto-merge (squash) November 13, 2026 14:05
@BYK
BYK merged commit d20f539 into main Nov 13, 2026
43 checks passed
@BYK
BYK deleted the feat/api-base-path-export branch November 13, 2026 14:14

This branch was successfully deployed

1 active deployment
Preview — 27aae8c2 Deployed Nov 13, 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