Files
twenty/packages
sonarly-bot 24fc02a884 fix: stop masking transient Postgres errors as validation errors
https://sonarly.com/issue/41962?type=bug

Person create/delete mutations can fail with a generic INTERNAL_SERVER_ERROR “Data validation error.” instead of the real database failure, blocking core CRM record management for affected workspaces.

Fix: I first checked recent history as requested (`git log --all --oneline --since='30 days ago' -- <affected files>`) and did not find an existing commit that fixed this exact root cause in `computeTwentyORMException`.

Then I implemented the code fix in the ORM exception adapter:
- Added an explicit set of Postgres data-validation error codes (e.g. FK/NOT NULL/CHECK violations and related data-shape errors).
- Kept the generic `Data validation error.` masking only for that validation subset.
- For other recognized Postgres errors (including transient concurrency errors like deadlock/serialization), preserved the original DB message when building `PostgresException`.

This removes the broad masking behavior that was rewriting all recognized Postgres failures to the same validation message, while preserving safe masking where it still makes sense.

I also added focused tests to lock this behavior:
- invalid text representation -> `TwentyORMExceptionCode.INVALID_INPUT`
- validation-class Postgres error -> still generic `Data validation error.`
- transient deadlock error -> preserves original message (`deadlock detected`)

Authored by Sonarly by autonomous analysis (run 47884).
2026-06-01 18:48:24 +00:00
..
2026-05-04 11:09:34 +02:00
2026-05-27 14:33:57 +02:00