Skip to content

ref(profiling): document chunks project param as ID-or-slug, not int#118051

Merged
betegon merged 1 commit into
masterfrom
ref/profiling-chunks-project-param-slug
Jun 19, 2026
Merged

ref(profiling): document chunks project param as ID-or-slug, not int#118051
betegon merged 1 commit into
masterfrom
ref/profiling-chunks-project-param-slug

Conversation

@betegon

@betegon betegon commented Jun 18, 2026

Copy link
Copy Markdown
Member

What

The profiling chunks endpoint (GET /organizations/{org}/profiling/chunks/) declares its project query param as type=int ("The ID of the project"), while the sibling flamegraph endpoint — same base class (OrganizationProfilingBaseEndpoint), same get_snuba_params parsing — documents the same project param via OrganizationParams.PROJECT as accepting IDs or slugs.

The runtime already resolves slugs → numeric project ids in get_snuba_params (Snuba only ever receives numeric ids), so type=int is an under-specification, not a real numeric-only contract.

This changes it to type=str ("ID or slug"), keeping the existing "exactly one project must be specified" semantics (still enforced in the handler).

Why it matters (downstream)

The generated @sentry/api SDK typed chunks' project as a scalar number. Consumers (e.g. sentry-mcp) therefore coerced input with Number(projectId) — which turns a project slug into NaN and breaks slug-based profile-chunk lookups. With this change the SDK regenerates project as a string, so consumers can forward an ID or slug directly (no coercion, no cast).

Scope

  • Pure OpenAPI-declaration change in one OpenApiParameter. No runtime behavior change — the handler and get_snuba_params are untouched.
  • Not a Snuba change: slug→id resolution lives in sentry's get_snuba_params; Snuba receives numeric ids regardless.

Verification

sentry django spectacular --validate --fail-on-warn is clean, and the generated project param schema is now {"type": "string"} (was integer), with the description updated to "ID or slug". The frontend calls this endpoint via PageFilters (numeric project ids), which remain valid.

cc @getsentry/profiling (owners) — flagging in case the scalar int was intentional; if chunks is meant to be numeric-only, happy to instead align the consumer side, but the shared runtime + the flamegraph sibling suggest IDs-or-slugs is correct.

The profiling chunks endpoint declared its `project` query param as
`type=int` ("The ID of the project"), while the sibling flamegraph endpoint —
same base class, same `get_snuba_params` parsing — documents the same param via
OrganizationParams.PROJECT as accepting IDs *or slugs*. The runtime resolves
slugs to numeric ids in get_snuba_params before anything reaches Snuba, so
`type=int` was an under-specification.

Effect downstream: the generated @sentry/api SDK typed chunks' `project` as a
scalar `number`, forcing consumers (e.g. sentry-mcp) to coerce with Number() —
which turns a project slug into NaN and breaks slug-based lookups.

Change the param to `type=str` ("ID or slug"), keeping the 'exactly one project'
semantics enforced in the handler. Pure OpenAPI-declaration change; no runtime
behavior change.

Verified: spectacular --validate --fail-on-warn clean; generated param is now string.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 18, 2026
@betegon betegon marked this pull request as ready for review June 18, 2026 19:15
@betegon betegon requested a review from a team as a code owner June 18, 2026 19:15
@betegon betegon merged commit 6ae48d7 into master Jun 19, 2026
64 of 65 checks passed
@betegon betegon deleted the ref/profiling-chunks-project-param-slug branch June 19, 2026 07:32
betegon added a commit to getsentry/sentry-mcp that referenced this pull request Jun 19, 2026
getsentry/sentry#118051 fixed the profiling-chunks `project` param to be
documented as an ID-or-slug (string) instead of a scalar int, so @sentry/api
0.232.0 now types getProfileChunk's `project` as string.

Replace the temporary `projectId as number` cast with `String(projectId)` —
numeric ids serialize as-is, slugs are preserved, no cast. The slug guard test
still passes.

Verified: tsc clean (no other breakage from 0.228->0.232); full mcp-core suite
unchanged (1162 pass; the 2 fails remain the pre-existing autofix
run_id/sentry_run_id tests, tracked separately).
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants