Skip to content

fix: allow larger import batches in BufferedConsumer - #210

Draft
rahul-mixpanel wants to merge 2 commits into
masterfrom
rahulraveendran-sdk-365-python-115-bufferedconsumer-limits
Draft

rahul-mixpanel wants to merge 2 commits into
masterfrom
rahulraveendran-sdk-365-python-115-bufferedconsumer-limits

Conversation

@rahul-mixpanel

@rahul-mixpanel rahul-mixpanel commented Nov 27, 2026 •

Copy link
Copy Markdown

No description provided.

BufferedConsumer caps every endpoint at 50 messages per request, but
/import accepts up to 2000 events per request. Add an opt-in
import_max_size argument (capped at 2000) for the imports buffer. It
defaults to max_size, so existing callers send exactly what they send
today.

Related to #115

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Nov 27, 2026

Copy link
Copy Markdown

SDK-365

@codecov

codecov Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.54%. Comparing base (c44c420) to head (c802165).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #210      +/-   ##
==========================================
+ Coverage   96.51%   96.54%   +0.02%     
==========================================
  Files          15       15              
  Lines        2955     2980      +25     
  Branches      180      182       +2     
==========================================
+ Hits         2852     2877      +25     
  Misses         66       66              
  Partials       37       37              
Flag Coverage Δ
openfeature-provider 51.48% <10.00%> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5 · The previous oversized-request issue still needs a fix before merging.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change is limited to how import messages are batched.

The previous oversized-request issue still needs a fix before merging.

Findings

  1. P1 Larger batches exceed request limits ▶
Fix with agent prompt
### Issue 1
mixpanel/__init__.py:973-977
With `import_max_size=2000`, 2000 events of roughly 6 KB become one roughly 12 MB request. That exceeds the 10 MB import limit stated in the PR description, although the same events previously fit in 50-event batches. `_flush_endpoint` splits only by event count, so another `flush()` retries the same oversized batch.

Split import batches by encoded size as well as count, and add a test with large events.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (2) · Last reviewed commit: "fix(analytics): reject non-positive impo..." · Reviewed by Greptile

Comment thread mixpanel/__init__.py
Comment on lines +969 to 973
max_size = self._endpoint_max_size(endpoint)

while buf:
batch = buf[: self._max_size]
batch = buf[:max_size]
batch_json = "[{}]".format(",".join(batch))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Larger batches exceed request limits

With import_max_size=2000, 2000 events of roughly 6 KB become one roughly 12 MB request. That exceeds the 10 MB import limit stated in the PR description, although the same events previously fit in 50-event batches. _flush_endpoint splits only by event count, so another flush() retries the same oversized batch.

Split import batches by encoded size as well as count, and add a test with large events.

Prompt To Fix With AI
This is a comment left during a code review.
Path: mixpanel/__init__.py
Line: 969-973

Comment:
**Larger batches exceed request limits**

With `import_max_size=2000`, 2000 events of roughly 6 KB become one roughly 12 MB request. That exceeds the 10 MB import limit stated in the PR description, although the same events previously fit in 50-event batches. `_flush_endpoint` splits only by event count, so another `flush()` retries the same oversized batch.

Split import batches by encoded size as well as count, and add a test with large events.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

import_max_size=0 or below made flush loop forever, because the batch
slice was always empty. Raise ValueError for the new argument, and note
that large import batches can exceed the 10 MB /import request limit.

Related to #115

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant