Repository navigation
Fix: use independent fixtures in ClampsOverlappedPct test - #17416
Conversation
📝 WalkthroughWalkthroughThe chunker overlap clamping test now creates fresh input for each ChangesOverlap clamping test isolation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/ingestion/component/chunker/token_batch1_test.go`:
- Around line 94-95: Update the first chunk’s Text fixture in the affected
token-batch test cases to contain just over 128 tokens, such as 130, instead of
100. Keep the second chunk and assertions unchanged so the fixture distinguishes
the clamped zero-overlap threshold from unclamped negative percentages.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1a139274-0fc8-4c23-b6de-95f8c9e62ede
📒 Files selected for processing (1)
internal/ingestion/component/chunker/token_batch1_test.go
mergeByTokenSizeFromJSON mutates its perItem argument in place and returns the same backing array (token.go). Reusing one fixture across the four calls let later calls reprocess already-merged chunks and silently overwrite the earlier results via aliasing, so reflect.DeepEqual was vacuously true - the test passed without actually exercising the clamp (review comment on PR infiniflow#17396). Build a fresh fixture per call. The first chunk now carries TKNums 130, just above chunk_token_size 128, so both clamp directions are exercised: at pct=0 (threshold 128) the chunks stay split, while an unclamped negative pct raises the threshold (e.g. -5 -> 134.4) and merges them - which would otherwise make the lower-clamp assertions pass even if the clamp were removed (review: coderabbitai on PR infiniflow#17416). Verified the test now fails (negative-case assertions at token_batch1_test.go:128/131; panic at token.go:768 for the upper case) when the clamp is disabled, confirming it is no longer a false positive.
868acc8 to
de8bb64
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/ingestion/component/chunker/token_batch1_test.go (1)
84-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove review-history references from the helper comment.
The PR/reviewer references on Lines 90 and 97 will go stale. Keep the current mutation and threshold rationale, but remove the historical attribution. As per coding guidelines, Go comments should describe the current runtime path rather than migration history.
Proposed cleanup
-// (see code review on PR `#17396`). ... -// (review: coderabbitai on PR `#17416`).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/ingestion/component/chunker/token_batch1_test.go` around lines 84 - 97, Update the clampOverlapFixture comment to retain the explanation of per-call slice freshness, mutation/aliasing behavior, and threshold coverage, while removing all PR numbers, reviewer attributions, and other review-history references. Keep the comment focused on the current runtime behavior and test rationale.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/ingestion/component/chunker/token_batch1_test.go`:
- Around line 84-97: Update the clampOverlapFixture comment to retain the
explanation of per-call slice freshness, mutation/aliasing behavior, and
threshold coverage, while removing all PR numbers, reviewer attributions, and
other review-history references. Keep the comment focused on the current runtime
behavior and test rationale.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5ec72e1d-5ebf-4402-8716-2174308d8637
📒 Files selected for processing (1)
internal/ingestion/component/chunker/token_batch1_test.go
|
@yingfeng @yuzhichang @JinHai-CN Pls help to review. |
Problem
TestMergeByTokenSizeFromJSON_ClampsOverlappedPctreused a singleitemsfixture across four calls tomergeByTokenSizeFromJSON.mergeByTokenSizeFromJSONmutates itsperItemargument in place and returns the same backing array (token.go:perItem[idx] = merged). As a result:at100,at0, ...).reflect.DeepEqual(at100, at150)was therefore vacuously true — the test was a false positive that never actually exercised the clamp. It would still pass even if the clamp were broken.This is exactly the defect flagged in the review comment on PR #17396.
Fix
Add a
clampOverlapFixture()factory and build a fresh fixture for every call, so that 150 / 1e300 / -5 / -1e300 are applied to the original input.Verification
Scope
Test file only. No production code change (verified
token.gois identical toupstream/main).Refs: review comment on PR #17396.