Repository navigation
Conversation
Use explicit None checks for chunk_count, token_count, and progress so falsy but valid values still run the immutability guard.
|
Friendly follow-up: this PR is non-draft and mergeable with a focused immutability-guard fix plus regression tests for zero-valued fields. Validated locally:
Could a maintainer please add the |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesFalsy-value immutability fix and regression tests
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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.
🧹 Nitpick comments (1)
test/unit_test/api/utils/test_doc_validation.py (1)
178-202: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd isolated mismatch tests for
token_countandprogress.The new mismatch test exits on
chunk_countfirst, so regressions in zero-value checks fortoken_count/progresscould still slip through. Add focused cases where earlier fields match and each later field mismatches independently.🤖 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 `@test/unit_test/api/utils/test_doc_validation.py` around lines 178 - 202, The new zero-value regression coverage in test_validate_immutable_fields_zero_values_must_match only exercises the first failing field, so it can miss similar bugs in validate_immutable_fields for later fields. Add separate isolated tests in test_validate_immutable_fields_zero_values_must_match coverage where chunk_count matches but token_count mismatches, and another where chunk_count and token_count match but progress mismatches. Use UpdateDocumentReq, Mock, and validate_immutable_fields to verify each case returns the expected RetCode.DATA_ERROR and the corresponding immutable-field message.
🤖 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 `@test/unit_test/api/utils/test_doc_validation.py`:
- Around line 178-202: The new zero-value regression coverage in
test_validate_immutable_fields_zero_values_must_match only exercises the first
failing field, so it can miss similar bugs in validate_immutable_fields for
later fields. Add separate isolated tests in
test_validate_immutable_fields_zero_values_must_match coverage where chunk_count
matches but token_count mismatches, and another where chunk_count and
token_count match but progress mismatches. Use UpdateDocumentReq, Mock, and
validate_immutable_fields to verify each case returns the expected
RetCode.DATA_ERROR and the corresponding immutable-field message.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f55863a2-77b6-427d-bced-d4108031f34a
📒 Files selected for processing (2)
api/utils/validation_utils.pytest/unit_test/api/utils/test_doc_validation.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16309 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
validate_immutable_fields()to use explicitis not Nonechecks forchunk_count,token_count, andprogressProblem
Submitting
chunk_count=0,token_count=0, orprogress=0.0bypassed the immutability guard because the function used truthiness checks. That allowed clients to attempt direct updates to immutable document metadata with valid zero values.Test plan
.v/bin/pytest test/unit_test/api/utils/test_doc_validation.py -q -k immutable→ 11 passed.v/bin/ruff check api/utils/validation_utils.py test/unit_test/api/utils/test_doc_validation.py