fix: reinfer transformed value types - #31
Conversation
|
Warning Review limit reachedNext included review available in 50 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. Walkthrough
Changes规则归一化与验证
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change prevents reused schemas from retaining a stale inferred type after transformation without changing public entry points or adding dependencies. The supplied checks pass, and no actionable merge-blocking risk remains after normal review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #31 +/- ##
==========================================
+ Coverage 82.38% 82.44% +0.05%
==========================================
Files 25 25
Lines 653 655 +2
Branches 236 240 +4
==========================================
+ Hits 538 540 +2
Misses 114 114
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Problem
When a transform rule omits an explicit type, validate infers the type from the transformed value. That inference currently happens before the rule object is cloned, so the inferred type is written back into the Schema rules. Reusing the same Schema with a different transformed value type then validates against the stale type from the first call.
For example, a schema with an identity transform accepts a number first, but incorrectly rejects a string on the next validation because number was persisted as the rule type.
Validation
Duplicate audit
I checked all current open issues and PRs plus repository searches for transform/schema/type reuse. The only open PR is the TypeScript dependency update (#28), and issue #18 concerns Promise typing; neither overlaps this change.
AI assistance disclosure: Codex was used to trace the mutation, write the regression test, run validation, and audit open work. The failure and fix were verified locally against current master.
Summary by CodeRabbit
Bug 修复
测试