Skip to content

fix(otel): fall back to default batch limit for overlong numeric values - #1911

Open
hassiebp wants to merge 1 commit into
mainfrom
hassiebbot/otel-batch-limit-overlong-digits-5224
Open

hassiebp wants to merge 1 commit into
mainfrom
hassiebbot/otel-batch-limit-overlong-digits-5224

Conversation

@hassiebp

@hassiebp hassiebp commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Follow-up to #1909. If LANGFUSE_OTEL_MAX_BATCH_SIZE_BYTES is an all-digit string longer than Python's integer conversion limit (4,300 digits on 3.11+), int() raises ValueError. That error propagated out of Langfuse() initialization. Now such values are handled like any other invalid value: a warning is logged and the default 64 MiB limit is kept.

This was flagged by the Codex, Greptile and Claude reviews on #1909.

Type of change

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

Verification

The existing invalid-values test gained an overlong-digits case (5,000 nines). It failed with ValueError before the fix.

uv run --frozen ruff check .                      # All checks passed!
uv run --frozen mypy langfuse --no-error-summary
uv run --frozen pytest -n auto --dist worksteal tests/unit -q   # 710 passed, 2 skipped

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.
Open in Web Open in Cursor 

RetriggerConfidence Score: 4/5

The PR appears safe to merge, though the new regression test should be made independent of the runtime integer-string limit.

Summary

The PR catches integer-conversion failures for the OTel batch-size environment variable and adds a regression case. The new test assumes a runtime conversion limit that is not guaranteed in every supported configuration.

Reviews (1) · Last reviewed commit: "fix(otel): fall back to default batch li..."

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T09:59:39.502559Z 3338556 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

@claude review

@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

No review was started: this request came from a bot account. Manual reviews can only be requested by someone with write access to this repository. Ask a maintainer to comment @claude review, or have your automation post the comment from a user account with write access.

Tip: disable this comment in your organization's Code Review settings.

@pytest.mark.parametrize("raw_value", ["0", "-5", "abc", "1.5"])
@pytest.mark.parametrize(
"raw_value",
["0", "-5", "abc", "1.5", pytest.param("9" * 5000, id="overlong-digits")],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Test depends on Python limit

If Python's integer-string digit limit is disabled, or the test runs on an older Python 3.10 patch release without that limit, converting the 5,000-digit value succeeds. The resolver then uses that positive value instead of the default, so this test fails its limit and warning assertions. Make the test establish a conversion limit or account for runtimes without one.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/unit/test_span_processor.py
Line: 201

Comment:
**Test depends on Python limit**

If Python's integer-string digit limit is disabled, or the test runs on an older Python 3.10 patch release without that limit, converting the 5,000-digit value succeeds. The resolver then uses that positive value instead of the default, so this test fails its limit and warning assertions. Make the test establish a conversion limit or account for runtimes without one.

---

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

@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.

Looks good — a small, correct fix for the ValueError on overlong numeric env values, with a regression test covering the exact failure mode.

Extended reasoning...

The change touches only _resolve_max_batch_size_bytes() in span_processor.py, wrapping int(raw_value) in try/except ValueError to handle Python 3.11+'s int-to-str conversion digit limit, falling back to the existing 0/warning/default-limit path. No security-sensitive surface (auth, crypto, permissions) is touched; it's parsing of a local env var into a batch-size int. The test change adds a single parametrized case (5000-digit string) to an existing test, which I confirmed exercises the new except branch. Small, self-contained, mechanical fix with clear intent and test coverage, matching the described bug precisely.

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.

2 participants