Files
twenty/packages
sonarly-bot bab771b718 fix: ignore unknown fields in SSE optimistic update path
https://sonarly.com/issue/39857?type=bug

A frontend runtime error is thrown while processing SSE update events for a custom object, breaking live-update handling on that object page. The error is user-visible and blocks normal interaction flow for affected records/workspaces.

Fix: Implemented a targeted frontend fix for the SSE optimistic update crash caused by unknown custom-object fields:

1) Extracted unknown-field detection into a reusable helper:
- Added `getUnknownOptimisticRecordInputFields(...)` in `computeOptimisticRecordFromInput.ts`.
- `computeOptimisticRecordFromInput(...)` now reuses that helper and keeps existing strict throw behavior unchanged for its normal callers.

2) Fixed SSE UPDATED event handling to be resilient to metadata/data drift:
- In `useTriggerOptimisticEffectFromSseUpdateEvents.ts`, before optimistic computation, I compute unknown fields and sanitize `updatedRecord` by removing unknown keys.
- The sanitized payload is then used for store upsert and optimistic record computation, preventing the previous throw path from breaking SSE processing.

3) Added test coverage for the extracted helper:
- In `computeOptimisticRecordFromInput.test.ts`, added a test asserting unknown fields are correctly identified while known fields are excluded.
- Existing strict throw test remains intact, confirming strict mode still applies outside the SSE sanitization path.

Authored by Sonarly by autonomous analysis (run 45433).
2026-05-22 20:09:04 +00:00
..
2026-05-04 11:09:34 +02:00