Repository navigation
fix(scores): drop score events above LANGFUSE_MAX_EVENT_SIZE_BYTES - #1970
Open
moneebullah25 wants to merge 2 commits into
Open
moneebullah25 wants to merge 2 commits into
moneebullah25 wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
What does this PR do?
LANGFUSE_MAX_EVENT_SIZE_BYTESwas parsed intoMAX_EVENT_SIZE_BYTESbut never used, so a 10 MB score was posted as a single request.ScoreIngestionConsumer._next()now drops any score event whose serialized size is above the limit, logs an error with the event id, size and limit (never the payload), and acknowledges the queue item soflush()/join()do not hang.Behavior choice: the issue offers "dropped (with a logged error) or truncated". Dropping is the least surprising: truncating would silently change user data. A size exactly equal to the limit is allowed. The limit applies to the serialized event (id, type, timestamp, body), measured with the same encoder that is posted.
Not changed (separate points in the issue): checking the batch limit before appending (with this fix a batch can overshoot
MAX_BATCH_SIZE_BYTESby at most one event of at mostMAX_EVENT_SIZE_BYTES), and the import-timeint()parsing of the env var. Logging of 4xx batch drops is covered by #1874.Fixes #1966
Type of change
Verification
List the main commands you ran:
uv run --frozen ruff check . uv run --frozen ruff format --check langfuse tests/unit/test_score_ingestion_consumer.py uv run --frozen mypy langfuse --no-error-summary uv run --frozen pytest tests/unit/test_score_ingestion_consumer.py uv run --frozen pytest -n auto --dist worksteal tests/unitNotes: the new tests fail without the fix and pass with it.
ruff format --check .reportstests/unit/test_media.pyas unformatted on current main (untouched by this PR). In the full unit run,tests/unit/test_prompt.pyerrors unlessLANGFUSE_PUBLIC_KEY/LANGFUSE_SECRET_KEYare set in the environment; with dummy keys it passes (26 passed). Everything else passed (869 passed, 2 skipped).Checklist
code_review.md..env.templateif needed.
Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Drops score events above
MAX_EVENT_SIZE_BYTESbefore uploading them. Events exactly at the limit remain allowed.moneebullah25explicitly deferred batch-limit enforcement and import-time environment parsing as separate work. The author also stated that logging dropped batches after HTTP 4xx responses is covered by fix: log non-retryable 4xx batch drops and warn on silently ignored sample_rate #1874.Reviews (1) · Last reviewed commit: "fix(scores): drop score events above LAN..." · Reviewed by Greptile