https://sonarly.com/issue/15168?type=bug
The timeline activity worker crashes when processing events for custom objects whose morph relation field is missing from the timelineActivity object metadata, causing timeline activity recording to fail silently for affected workspaces.
Fix: **Fix:** Added a metadata validation check in `TimelineActivityRepository.upsertTimelineActivities()` that verifies the morph relation field exists in the `timelineActivity` object metadata before constructing queries with it.
**What changed:**
1. **`timeline-activity.repository.ts`**: Added `hasTimelineActivityMorphRelationField()` method that loads the workspace's flat entity maps, finds the `timelineActivity` object metadata, and checks whether the expected join column name exists in the field maps. If the field is missing, `upsertTimelineActivities()` logs a warning and returns early instead of letting `formatData` crash.
2. **`object-metadata-repository.module.ts`**: Updated the factory to inject `WorkspaceManyOrAllFlatEntityMapsCacheService` into repositories created through this module, so `TimelineActivityRepository` can access workspace metadata for validation.
**Why this approach:**
- Fixes the crash at the right layer (timeline repository) rather than suppressing errors in the shared `formatData` utility
- Preserves the strict validation in `formatData` (which catches other metadata inconsistencies)
- Logs a clear warning with actionable guidance (run workspace:sync-metadata)
- Matches the team's pattern of using `WorkspaceManyOrAllFlatEntityMapsCacheService` for metadata lookups (already used in `TimelineActivityService`)