Use model_validate() instead of model_copy() in UpdateUseCase#89
Closed
monkeypants wants to merge 1 commit into
Closed
Use model_validate() instead of model_copy() in UpdateUseCase#89monkeypants wants to merge 1 commit into
monkeypants wants to merge 1 commit into
Conversation
model_copy(update=data) skips Pydantic model validators, which bypasses invariants like auto-setting timestamps on state transitions. Use model_validate() to reconstruct the entity so all validators fire on partial updates.
Contributor
Author
|
Commit cherry-picked directly onto docs_architecture_domain (d5959a3). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
model_copy(update=data)withmodel_validate({**entity.model_dump(), **data})inUpdateUseCasemodel_copy()skips Pydantic model validators, bypassing invariants like auto-settingcompleted_aton state transitionsck_gtd_items_completed_atconstraint violations in downstream consumers (bingo-frog Sentry BF-BACKEND-ALPHA-2/3)Test plan
completed_atis auto-set when dropping a GTD item