Skip to content

chore(event): smaller limits for event list api#60124

Merged
nickbest-ph merged 4 commits into
masterfrom
nick/event-list-deprecated-endpoint-reduce-limit
May 26, 2026
Merged

chore(event): smaller limits for event list api#60124
nickbest-ph merged 4 commits into
masterfrom
nick/event-list-deprecated-endpoint-reduce-limit

Conversation

@nickbest-ph
Copy link
Copy Markdown
Contributor

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,000
  • New EVENT_LIST_MAX_LIMIT = 1_000: replaces the global MAX_SELECT_RETURNED_ROWS (50,000) as the cap for this endpoint only

This 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?

  • existing tests should cover existing behaviour
  • added test to make sure we adhere to limit

Docs update

🤖 Agent context

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

🎭 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 run-playwright label if you want an E2E sweep before merging — CI will pick it up automatically.

Most PRs don't need this. Real regressions still get caught on master and fix-forward.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 26, 2026

Prompt To Fix All With AI
Fix 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

Comment thread posthog/api/test/test_event.py
@tests-posthog
Copy link
Copy Markdown
Contributor

tests-posthog Bot commented May 26, 2026

⏭️ Skipped snapshot commit because branch advanced to e527606 while workflow was testing cbc912c.

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:

  • Merge master into your branch, or
  • Push an empty commit: git commit --allow-empty -m 'trigger CI' && git push

@nickbest-ph nickbest-ph merged commit 54b60f5 into master May 26, 2026
297 of 299 checks passed
@nickbest-ph nickbest-ph deleted the nick/event-list-deprecated-endpoint-reduce-limit branch May 26, 2026 23:29
@deployment-status-posthog
Copy link
Copy Markdown

deployment-status-posthog Bot commented May 26, 2026

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-05-26 23:52 UTC Run
prod-us ✅ Deployed 2026-05-27 00:02 UTC Run
prod-eu ✅ Deployed 2026-05-27 00:04 UTC Run

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants