Closes [89](https://github.com/twentyhq/core-team-issues/issues/89) ## Problem When users attempt to create or update a record with a duplicate value for a unique field (e.g., duplicate email or domain name), they receive a generic error message: "This record already exists. Please check your data and try again." This provides no actionable way to locate and view the existing conflicting record, forcing users to manually search for it. ## Solution This PR enhances duplicate key constraint error handling to automatically detect the conflicting record and display a "View existing record" link in the error notification. When clicked, users are navigated directly to the existing record's detail page. ## Backend Changes ### 1. PostgreSQL Error Parsing (`parse-postgres-constraint-error.util.ts`) - Extracts structured information from PostgreSQL `QueryFailedError` messages. ### 2. Conflicting Record Lookup (`find-conflicting-record.util.ts`) - Queries the database to find the existing record with the conflicting value ### 3. Error Handling Orchestration (`handle-duplicate-key-error.util.ts`) - Parses PostgreSQL error to extract column name and conflicting value - Attempts to find the conflicting record - Enriches `TwentyORMException` with `conflictingRecordId` and `conflictingObjectNameSingular` if found ### 4. Exception Computation Updates (`compute-twenty-orm-exception.ts`) - Made function `async` and added optional `entityManager` and `internalContext` parameters - Needed to support async database queries for conflicting record lookup ### 5. GraphQL Error Handler (`twenty-orm-graphql-api-exception-handler.util.ts`) - **Changes**: Enhanced `DUPLICATE_ENTRY_DETECTED` case to include `conflictingRecordId` and `conflictingObjectNameSingular` in GraphQL error extensions ## Frontend Changes ### 1. Error Extraction Utility (`get-conflicting-record-from-apollo-error.util.ts`) - Accesses GraphQL error extensions - Validates that both `conflictingRecordId` and `conflictingObjectNameSingular` exist and are strings - Returns `null` if validation fails ### 2. SnackBar Enhancement (`useSnackBar.ts`) - Extracts conflicting record info from Apollo error - Constructs URL using `getAppPath` utility - Adds link object to snackbar options with text "View existing record" <img width="931" height="858" alt="image" src="https://github.com/user-attachments/assets/28137dc7-18ab-4ffe-b669-1f2d4ec264d1" />
The #1 Open-Source CRM
🌐 Website · 📚 Documentation · Roadmap ·
Discord ·
Figma
Installation
See: 🚀 Self-hosting 🖥️ Local Setup
Does the world need another CRM?
We built Twenty for three reasons:
CRMs are too expensive, and users are trapped. Companies use locked-in customer data to hike prices. It shouldn't be that way.
A fresh start is required to build a better experience. We can learn from past mistakes and craft a cohesive experience inspired by new UX patterns from tools like Notion, Airtable or Linear.
We believe in Open-source and community. Hundreds of developers are already building Twenty together. Once we have plugin capabilities, a whole ecosystem will grow around it.
What You Can Do With Twenty
Please feel free to flag any specific needs you have by creating an issue.
Below are a few features we have implemented to date:
- Personalize layouts with filters, sort, group by, kanban and table views
- Customize your objects and fields
- Create and manage permissions with custom roles
- Automate workflow with triggers and actions
- Emails, calendar events, files, and more
Personalize layouts with filters, sort, group by, kanban and table views
Customize your objects and fields
Create and manage permissions with custom roles
Automate workflow with triggers and actions
Emails, calendar events, files, and more
Stack
- TypeScript
- Nx
- NestJS, with BullMQ, PostgreSQL, Redis
- React, with Recoil, Emotion and Lingui
Thanks
Thanks to these amazing services that we use and recommend for UI testing (Chromatic), code review (Greptile), catching bugs (Sentry) and translating (Crowdin).
Join the Community
- Star the repo
- Subscribe to releases (watch -> custom -> releases)
- Follow us on Twitter or LinkedIn
- Join our Discord
- Improve translations on Crowdin
- Contributions are, of course, most welcome!




