events-timeseries API: grouped (topEvents) queries on errors and discover datasets return 500
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 44.8k
- Forks
- 4.9k
- Avg merge
- 21h 23m
- Merged PRs (30d)
- 607
Description
Grouped queries against the documented /api/0/organizations/{org}/events-timeseries/ endpoint return HTTP 500 {"detail":"Internal Error"} for the errors and discover datasets, while the same queries succeed ungrouped and succeed grouped on the spans dataset.
Repro (any org with error events):
GET /api/0/organizations/{org}/events-timeseries/?dataset=discover&yAxis=count()&interval=3600&statsPeriod=1d&groupBy=project&sort=-project&topEvents=5
Expected: a grouped time series, as documented. Actual: 500 {"detail":"Internal Error"}. Example error IDs from 2026-07-17: 2f71f4784f1b44189ebc0677875b5f52, 41cccfe4a6e94063816aed11153d3add, 5aa8d048c1624638b9d853e92a4d35d3.
The same request shape returned 200 earlier on 2026-07-17, so this looks like a regression rather than an intended contract change. It reproduces with statsPeriod or start/end, with and without sort, and with excludeOther=0 or 1. Ungrouped requests on the same datasets return 200, and grouped requests with dataset=spans return 200.
Impact: the Grafana Sentry data source migrated its Events Stats queries to this endpoint and has had to route grouped queries back to the legacy events-stats endpoint until this is resolved.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the documented /api/0/organizations/{org}/events-timeseries/ request with dataset=discover or errors, groupBy=project, and topEvents=5, then compare it with an ungrouped request and the working spans dataset. Trace the grouped query handling for these datasets and use the listed error IDs to inspect the failure. Done means grouped errors and discover queries return a time series with HTTP 200, including the documented parameter variants.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100