https://sonarly.com/issue/41112?type=bug
Timeline updates omit MANY_TO_ONE relation changes, and relation-only updates can produce no visible activity entry at all. This breaks audit-trail completeness for common CRM edits.
Fix: Implemented a backend fix so relation changes are included in timeline update diffs and relation-only updates are no longer dropped as empty diffs.
What changed:
1) `packages/twenty-server/src/engine/core-modules/event-emitter/utils/object-record-changed-values.ts`
- Stopped excluding `FieldMetadataType.RELATION` from diff generation.
- Used both maps from `buildFieldMapsFromFlatObjectMetadata`:
- `fieldIdByName`
- `fieldIdByJoinColumnName`
- Added normalization of diff keys to metadata field names (`diffKey = field?.name ?? key`), so MANY_TO_ONE join column updates like `companyId` are emitted as `company`.
- Kept POSITION filtering intact.
This fixes both:
- missing relation diffs in update activities
- relation-only updates being filtered out downstream as empty diffs
and avoids frontend metadata lookup failures due to `...Id` diff keys.
2) `packages/twenty-server/src/engine/core-modules/event-emitter/utils/__tests__/object-record-changed-values.spec.ts`
- Added test: includes relation-field changes in diff.
- Added test: normalizes MANY_TO_ONE join-column changes (`companyId`) to relation field name (`company`) in diff output.
- Retained existing POSITION-ignore behavior test.
Validation attempts:
- Tried running:
`npx jest packages/twenty-server/src/engine/core-modules/event-emitter/utils/__tests__/object-record-changed-values.spec.ts --config=packages/twenty-server/jest.config.mjs`
- Blocked by environment dependency resolution error: `Cannot find module 'file-type'` from Jest config.
Authored by Sonarly by autonomous analysis (run 46864).