keep icon indicating copy to clipboard operation
keep copied to clipboard

[🐛 Bug]: Sentry provider pull reads only the first page of each project's events and issues

Open jobordu opened this issue 4 weeks ago • 1 comments

Describe the bug

The Sentry provider's pull (_get_alerts) reads only the first page of each project's listings, so a busy org silently loses issues.

For every project, it makes one GET /projects/{org}/{project}/events/ and one GET /projects/{org}/{project}/issues/?query=* (sentry_provider.py#L443-L503). Neither follows Sentry's cursor pagination (the Link: <...>; rel="next"; results="true" header), and neither sets a statsPeriod. Each request returns at most one page, so:

  • a project with more issues or recent events than one page gets only that page into Keep, with no warning;
  • query=* mixes resolved and unresolved issues in that one page, so an unresolved issue can be pushed off it by resolved ones;
  • an org with N projects costs 1 + 2N requests per pull.

Proposed fix

  1. Follow the Link rel="next" cursor (while results="true") on both listings, with a page cap that logs a warning when it is hit, rather than truncating silently.
  2. Optionally, when no project_slug is set, read issues once from the org endpoint, GET /api/0/organizations/{org}/issues/?project=-1&query=is:unresolved&statsPeriod=.... That is one paginated listing for every project, including ones created later. Each issue still carries its project, so per-project grouping is unchanged.

Context

Sentry SaaS cannot push webhooks to a Keep reachable only on a private network, so for those users pull is the only path, and truncation there means missed alerts. We work around it today with an external poller of the org endpoint that POSTs to /alerts/event/sentry.

I'll open a PR for (1) with tests, and (2) if maintainers want it.

jobordu avatar Nov 02 '26 18:11 jobordu

I have implemented cursor pagination following Sentry's RFC 5988 header with a safety page cap () across both and , backed by full unit tests in PR https://github.com/keephq/keep/pull/6926.

almagas avatar Nov 11 '26 00:11 almagas