Skip to content

fix(ingestion): do not retry score batches on 207 partial failure - #1968

Open
moneebullah25 wants to merge 3 commits into
langfuse:mainfrom
moneebullah25:fix/score-ingestion-207-partial-failure
Open

moneebullah25 wants to merge 3 commits into
langfuse:mainfrom
moneebullah25:fix/score-ingestion-207-partial-failure

Conversation

@moneebullah25

@moneebullah25 moneebullah25 commented Oct 9, 2026 •

Copy link
Copy Markdown

What does this PR do?

A 207 ingestion response with per-item errors raises APIErrors, which is not an APIError. The score consumer therefore treated it as a generic failure and re-POSTed the whole batch up to 3 times, and the per-item details only reached DEBUG.

This catches APIErrors in ScoreIngestionConsumer._upload_batch, logs one WARNING with the rejected count and up to 5 per-item messages (escaped, truncated to 200 chars), and does not retry. The "Successfully sent" debug line now only fires on real success.

Known limitation (noted in a code comment): per-item 429/5xx entries inside a 207 are not retried individually, since APIErrors does not carry the item id yet. The separate 4xx batch drop is intentionally not touched.

Fixes #1965

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Documentation update
  • Tooling, CI, or repo maintenance

Verification

List the main commands you ran:

.venv/bin/ruff check .
.venv/bin/ruff format --check langfuse tests/unit/test_resource_manager.py
.venv/bin/mypy langfuse --no-error-summary
.venv/bin/pytest tests/unit/test_resource_manager.py -q
.venv/bin/pytest tests/unit/test_otel.py -q
.venv/bin/pytest -n auto --dist worksteal tests/unit

Notes: uv run could not be used locally (installed uv 0.9.8 cannot parse this repo's uv.lock/exclude-newer), so tools were run from a venv with the project installed. ruff check passes; mypy reports no errors in the changed file (existing errors elsewhere come from the missing langchain/openai dev extras locally); test_resource_manager.py 13 passed, test_otel.py 65 passed. The full unit run had failures/errors only in modules needing the uninstalled langchain/openai extras (test_prompt, test_langchain, test_openai, etc.) and test_media.py has a pre-existing format diff; CI should cover those.

Checklist

  • I self-reviewed the diff using code_review.md.
  • I added or updated tests for behavior changes.
  • I updated docs, examples, or .env.template if needed.
  • I did not hand-edit generated files; if generated files changed, I used the upstream regeneration path.
  • I did not commit secrets or credentials.

RetriggerConfidence Score: 4/5

The PR appears safe to merge, with a non-blocking gap in tests for the changed logs.

Summary

Stops retrying whole score batches after a 207 response with item errors.

  • Logs one warning with the rejected count and up to five escaped, shortened error messages.
  • Logs “Successfully sent” only when the request succeeds.
  • Adds a regression test for no retry and warning output. The test should also check the changed logging safeguards.

Acknowledged limitations:

  • moneebullah25 explicitly acknowledged and deferred retries for per-item 429/5xx failures because APIErrors does not carry item IDs.
  • moneebullah25 explicitly stated that dropping non-429 batch-level 4xx failures is intentionally unchanged.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Send batch] --> B{Result}
    B -->|Success| C[Log success]
    B -->|207 with item errors| D[Log bounded warning; do not retry]
    B -->|Non-rate-limit 4xx| E[Do not retry]
    B -->|Other failure| F[Retry within existing limit]
    C --> G[Mark queue items done]
    D --> G
    E --> G
    F --> G
Loading

Reviews (1) · Last reviewed commit: bf505ce · Reviewed by Greptile

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@moneebullah25
moneebullah25 force-pushed the fix/score-ingestion-207-partial-failure branch 2 times, most recently from bf505ce to 1f54288 Compare October 9, 2026 10:18
@CLAassistant

CLAassistant commented Oct 9, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread tests/unit/test_resource_manager.py Outdated

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.

bug: Partial-failure (207) ingestion response retries the whole batch up to 3x; per-item error details only logged at DEBUG

2 participants