Skip to content

fix(trace): scope trace/span list by numeric project ID - #1364

Open
MathurAditya724 wants to merge 1 commit into
mainfrom
cursor/fix-traces-project-id-987e
Open

fix(trace): scope trace/span list by numeric project ID#1364
MathurAditya724 wants to merge 1 commit into
mainfrom
cursor/fix-traces-project-id-987e

Conversation

@MathurAditya724

Copy link
Copy Markdown
Member

Summary

Test plan

  • Unit tests for listTransactions / listSpans projectId scoping
  • Command tests assert projectId is threaded through
  • Production event confirms broken query shape (query=project:cuzz)
  • Live API check: query=project:operations-bot → 400 "not actively selected"; project=<numeric-id> succeeds
  • Manual: sentry traces <org>/<project> against a non-selected project slug

Closes nothing yet — tracks CLI-10 (command:sentry.trace.list) events.

Made with Cursor

`sentry traces` (and project-mode `span list`) scoped slug targets only via
`project:<slug>` search syntax on the Events API. That filter only matches
actively selected projects and otherwise returns 400 Bad Request
("Project(s) X do not exist or are not actively selected").

Resolve the slug to a numeric project ID and pass `project=<id>` instead,
mirroring the logs fix in #1318 / #1317 and the issues fix in #312.

Co-authored-by: Aditya Mathur <MathurAditya724@users.noreply.github.com>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Aug 5, 2026
@MathurAditya724 MathurAditya724 added the jared Trigger the Jared agent to work on stuff label Aug 5, 2026
@MathurAditya724

Copy link
Copy Markdown
Member Author

Jared Get this ready for merging, resolve all the issues you find in the review

@jared-outpost jared-outpost Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reviewed the diff, ran the affected suites, and traced the scoping logic — this is clean and ready.

what it does: threads a numeric projectId through listTransactions/listSpans so the events query scopes via the project= param instead of query=project:<slug>, which only matches actively-selected projects and 400s otherwise. same pattern as the #1317 logs fix.

things i verified:

  • resolveNumericProjectId correctly prefers the explicit id, falls back to an all-digits slug, and returns undefined otherwise so callers degrade to slug scoping rather than fail.
  • trace mode (allProjects) skips id resolution and still sends project=-1 — unchanged.
  • resolveLogProjectId re-throws user-actionable CliErrors (auth, host scope, 404) and only swallows genuinely transient failures, so a bad slug still fails loudly instead of silently degrading.
  • test coverage added for the new projectId path in both api and command layers; test/lib/api/traces, test/commands/trace/list, test/commands/span/list all pass locally. lint clean, CI green.

no findings. couldn't do the one unchecked manual step (live call against a non-selected slug) without prod creds, but the production event and live api check in the description already confirm the query shape. i can't merge a risk:medium PR without a human approval, so this is yours to land.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jared Trigger the Jared agent to work on stuff risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants