fix: domain inconsistencies — raw String in event VO and ImportSession constructor pattern #6
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Issues
1.
MovieEnrichmentRequestedusesStringinstead ofExternalMetadataIdcrates/domain/src/events.rs:Every other event carrying an external ID uses the VO.
ExternalMetadataIdvalidates non-empty and trims whitespace — using a rawStringhere means a malformed ID can slip through the event bus and fail silently later at the enrichment handler.Fix: change to
ExternalMetadataId, update all construction sites inreview_logger.rsandrequest_enrichment.rs, and update theevent-payloadserialization adapter accordingly.2.
ImportSession::new()takes an externally-providedImportSessionIdAll core models (
Movie,Goal,Review,User,UserSettings) follow the pattern:new()— domain generates the identity (XxxId::generate())from_persistence()— accepts an existing ID from the DBImportSession::new(id: ImportSessionId, ...)breaks this by requiring the caller to supply the ID, blurring the creation/reconstitution boundary.Fix: make
ImportSession::new()generate its own ID internally, addImportSession::from_persistence(id, ...)for the DB-load path.Affected files
crates/domain/src/events.rscrates/domain/src/models/import_session.rscrates/adapters/event-payload/src/lib.rscrates/application/src/diary/review_logger.rscrates/application/src/movies/request_enrichment.rscrates/adapters/sqlite/src/import_session.rscrates/adapters/postgres/src/(import session reconstitution)