Skip to content

[Python] Fix overflow in LexicographicKeyRangeTracker - #40330

Merged
jrmccluskey merged 1 commit into
apache:masterfrom
goutamadwant:fix-lexicographic-range-overflow
Sep 29, 2026
Merged

jrmccluskey merged 1 commit into
apache:masterfrom
goutamadwant:fix-lexicographic-range-overflow

Conversation

@goutamadwant

Copy link
Copy Markdown
Contributor

Fixes #26492

Long MongoDB string IDs can overflow when LexicographicKeyRangeTracker converts the integer delta to float before division.

This uses Python 3 true division directly and adds regression coverage for long bytes and str keys.

Before: 400-character keys raise OverflowError: int too large to convert to float.

After: the same keys return the expected fraction (0.48).

Tests:

  • python -m unittest -q apache_beam.io.range_trackers_test — 28 passed
  • python -m unittest -q apache_beam.io.mongodbio_test — 131 passed

@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.15%. Comparing base (b4db8d2) to head (cd7c2ec).

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #40330      +/-   ##
============================================
- Coverage     56.16%   56.15%   -0.01%     
  Complexity     2290     2290              
============================================
  Files          1121     1121              
  Lines        177158   177158              
  Branches       1486     1486              
============================================
- Hits          99494    99481      -13     
- Misses        75143    75156      +13     
  Partials       2521     2521              
Flag Coverage Δ
python 79.84% <100.00%> (-0.02%) ⬇️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @jrmccluskey for label python.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@goutamadwant

Copy link
Copy Markdown
Contributor Author

retest this please

@jrmccluskey jrmccluskey left a comment

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.

LGTM, thanks! Will merge after the precommit re-run finishes

@jrmccluskey
jrmccluskey merged commit f66e0ce into apache:master Sep 29, 2026
104 of 105 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Python ReadFromMongoDB/RangeTracker raises OverflowError

2 participants