Skip to content

fix(storage): replace unwrap() with expect() for u32 overflow in build()#90

Merged
poyrazK merged 1 commit intomainfrom
fix/positions-writer-u32-overflow-panics
May 2, 2026
Merged

fix(storage): replace unwrap() with expect() for u32 overflow in build()#90
poyrazK merged 1 commit intomainfrom
fix/positions-writer-u32-overflow-panics

Conversation

@poyrazK
Copy link
Copy Markdown
Owner

@poyrazK poyrazK commented May 2, 2026

Summary

  • Replace 4 unwrap() calls in PositionsWriter::build() with expect() calls that document the u32::MAX overflow condition
  • Affects: term_count, doc_count, pos_count, and term_bytes.len() conversions

Test plan

  • cargo test -p cloudsearch-storage — all 35 tests pass
  • cargo clippy --package cloudsearch-storage --all-targets — clean

PositionsWriter::build() used unwrap() on u32::try_from() conversions
at 4 locations (term_count, doc_count, pos_count, term_bytes.len).
These would panic if counts exceeded u32::MAX (~4B), which is
effectively impossible but the panic was undocumented.

Now uses expect() with descriptive messages documenting the
file-format constraint that limits these counts to u32::MAX.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

Warning

Rate limit exceeded

@poyrazK has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 35 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1eb2812f-51b5-44e5-8352-d4b98723ce35

📥 Commits

Reviewing files that changed from the base of the PR and between 9a843ed and b310030.

📒 Files selected for processing (1)
  • rust/crates/cloudsearch-storage/src/positions_writer.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/positions-writer-u32-overflow-panics

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 53 minutes and 35 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Owner Author

@poyrazK poyrazK left a comment

Choose a reason for hiding this comment

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

It's okay to merge

@poyrazK poyrazK merged commit 9ce969a into main May 2, 2026
4 checks passed
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