-
Notifications
You must be signed in to change notification settings - Fork 307
fix: model validator assignment consistency #1798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #1798 will not alter performanceComparing Summary
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
AI slop. |
@mot3 Please avoid generating whole PR descriptions and comments with AI. I want to interact with humans, not LLMs. It also unfortunately conveys that you may have generated the contribution with AI as well (which is actually the case almost every time when description are fully generated like this). I also closed this directly as it does not fix the actual issue when I tested locally. My original comment mentioned:
And not that the before validator received the updated model value, which looks like a separate issue. I'll discuss with the team today and report. |
Thanks @Viicos |
I have to mention something
As you can see, the before validator now correctly receives |
…te during assignment
6791004
to
da2af49
Compare
You're right - I think I got sidetracked while working on this. So my fix makes the values consistent between validator types, but doesn't solve the original dict vs instance type issue. I force changed my commit because I referenced them to that issue. |
Fix: Model validator assignment consistency
Summary
Fixes inconsistency in model-level validator behavior during field assignment validation when
validate_assignment=True
.Problem: During assignment operations,
@model_validator(mode='before')
and@model_validator(mode='wrap')
validators received different states:Solution: Modified assignment validation to ensure both validator modes consistently see the pre-update state.
Changes Made
Core Changes
src/validators/model.rs
:input_dict.set_item(field_name, field_value)?
inModelValidator::validate_assignment
Behavior Changes
Before this fix:
After this fix:
Testing
Manual Testing:
Regression Prevention:
Fixes
Closes #11823
Checklist
Type of change: 🐛 Bug fix
Affects: Model validators, assignment validation
Breaking: No