chore(event): smaller limits for event list api#60124
Merged
nickbest-ph merged 4 commits intoMay 26, 2026
Merged
Conversation
Contributor
|
🎭 Playwright didn't run on this PR — your changes touch code that could affect E2E behavior, but Playwright is opt-in via label now to keep CI cost down. Add the Most PRs don't need this. Real regressions still get caught on master and fix-forward. |
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
posthog/api/test/test_event.py:924-947
**Test doesn't actually exercise the cap**
The test creates only 1 event and then checks that `response["next"] is None`. With a single event in the DB, `next` will always be `None` regardless of whether the cap is 1,000 or 50,000 — so the assertion doesn't prove the cap is being applied. To verify enforcement, the test needs to insert more than `EVENT_LIST_MAX_LIMIT` events and assert that at most 1,000 are returned in a single response, even when `?limit=50000` is passed.
Reviews (1): Last reviewed commit: "adds test" | Re-trigger Greptile |
Contributor
|
⏭️ Skipped snapshot commit because branch advanced to The new commit will trigger its own snapshot update workflow. If you expected this workflow to succeed: This can happen due to concurrent commits. To get a fresh workflow run, either:
|
z0br0wn
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
/api/projects/:id/events/endpoint is deprecated but still serves some amount of traffic. For each request, it fetches full Person records for every distinct_id in the result set, just to extract 3 property keys (email,name,username) and a boolean (is_identified) per person.The endpoint previously allowed up to 50,000 events per request (via
?limit=50000) and defaulted to 3,500 for CSV exports. At the fat tail this produces person lookups returning thousands of full Person records with complete properties blobs.Changes
Cap the deprecated events list API to return at most 1,000 events per request, down from 50,000.
QUERY_DEFAULT_EXPORT_LIMIT(CSV export default): 3,500 → 1,000EVENT_LIST_MAX_LIMIT = 1_000: replaces the globalMAX_SELECT_RETURNED_ROWS(50,000) as the cap for this endpoint onlyThis is scoped entirely to
posthog/api/event.py— no other endpoints are affected.The PostHog frontend does not call this API (it uses the HogQL events query runner instead), so this only impacts external API consumers using a deprecated endpoint.
How did you test this code?
Docs update
🤖 Agent context