Skip to content

Use model_validate() instead of model_copy() in UpdateUseCase#89

Closed
monkeypants wants to merge 1 commit into
docs_architecture_domainfrom
fix-model-copy-skips-validators
Closed

Use model_validate() instead of model_copy() in UpdateUseCase#89
monkeypants wants to merge 1 commit into
docs_architecture_domainfrom
fix-model-copy-skips-validators

Conversation

@monkeypants

Copy link
Copy Markdown
Contributor

Summary

  • Replace model_copy(update=data) with model_validate({**entity.model_dump(), **data}) in UpdateUseCase
  • model_copy() skips Pydantic model validators, bypassing invariants like auto-setting completed_at on state transitions
  • This caused ck_gtd_items_completed_at constraint violations in downstream consumers (bingo-frog Sentry BF-BACKEND-ALPHA-2/3)

Test plan

  • All 82 julee use case tests pass
  • Downstream regression test confirms completed_at is auto-set when dropping a GTD item

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.
@monkeypants

Copy link
Copy Markdown
Contributor Author

Commit cherry-picked directly onto docs_architecture_domain (d5959a3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant