Skip to content

fix(cli): Scope explore to the project by ID, not project:<slug> - #1928

Merged
BYK merged 2 commits into
mainfrom
fix/cli-explore-project-id-scope
Nov 4, 2026
Merged

BYK merged 2 commits into
mainfrom
fix/cli-explore-project-id-scope

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

sentry explore <org>/<project> scoped the Events request with a project:<slug> query term and sent no project param. The API checks that term against the requester's member projects only. So if you query a valid project you aren't a member of, the request 400s. This is one of the root causes grouped under CLI-10 ("API request failed: 400"), hitting several orgs on 0.47.0.

The fix copies trace/span/log list (#1317). Explore now resolves the numeric project ID with resolveLogProjectId and sends project=<id> for table queries, --time-series, and --metric discovery. It still falls back to project:<slug> when the ID can't be resolved. Replays already scope with projectSlugs and are unchanged. A slug that doesn't exist now gets the existing "Project not found" resolution error with suggestions, not a raw 400.

Before

$ sentry explore my-org/my-proj -F title -F "count()"
Error: API request failed: 400 Bad Request
  Endpoint: /organizations/my-org/events/
  Invalid query. Project(s) my-proj do not exist or are not actively selected.
GET /api/0/organizations/my-org/events/?dataset=errors&field=title&field=count()&query=project:my-proj&sort=-count()&per_page=25&statsPeriod=24h

After

$ sentry explore my-org/my-proj -F title -F "count()"
Querying errors in my-org/my-proj:

╭────────────────────────────────────────────────┬─────────╮
│ TITLE                                          │ COUNT() │
├────────────────────────────────────────────────┼─────────┤
│ TypeError: Cannot read properties of undefined │     128 │
│ ReferenceError: foo is not defined             │      12 │
╰────────────────────────────────────────────────┴─────────╯

Showing 2 results.
GET /api/0/projects/my-org/my-proj/?collapse=organization
GET /api/0/organizations/my-org/events/?dataset=errors&field=title&field=count()&project=42&sort=-count()&per_page=25&statsPeriod=24h

The output above came from a local fake Sentry server that rejects project:<slug> without a project param, which matches the production error.

via bete.

--

View Session [Sentry]

`sentry explore <org>/<project>` scoped requests with a project:<slug>
query term and no project param. The Events API validates that term
against the requester's member projects, so a valid project the user
is not a member of failed with "Project(s) <slug> do not exist or are
not actively selected" (CLI-10).

Resolve the numeric ID like trace/span/log list (#1317) and send it as
project=<id> for tables, time series, and --metric discovery. Fall back
to project:<slug> only when the ID cannot be resolved. Replays keep
using projectSlugs.

Co-Authored-By: Miguel Betegon <miguel.betegon@sentry.io>
@vercel

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 4, 2026 9:49am UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 4, 2026
? parsePeriod(flags.period)
: flags.period;
const environment = parseReplayEnvironmentFilter(flags.environment);
// Events queries scope by numeric ID; replays take the slug directly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because why not? 🤣

@BYK
BYK merged commit f043904 into main Nov 4, 2026
27 checks passed
@BYK
BYK deleted the fix/cli-explore-project-id-scope branch November 4, 2026 14:44

This branch was previously deployed

1 inactive deployment
Preview — 70268862 Deployed Nov 4, 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