https://sonarly.com/issue/23367?type=bug
IMAP email sync fails because commit d3f0162cf5 removed the connected account feature flag, forcing all reads from the core schema where some IMAP accounts were never migrated due to unresolvable accountOwnerId→userWorkspaceId mappings in the 1.20 upgrade command.
Fix: Added null guards for `messageChannel.connectedAccount` at two critical points in the IMAP sync pipeline:
1. **`messaging-message-list-fetch.job.ts`** (line 83-92): After loading the message channel with its `connectedAccount` relation, check if the connected account exists before proceeding. If missing, track the error via the monitoring service and return early. This prevents the crash at line 110 where `messageChannel.connectedAccount.id` would throw on null access.
2. **`messaging-message-list-fetch.service.ts`** (line 100-107): Same guard after re-fetching the fresh message channel following pending action processing. Without this, `freshMessageChannel.connectedAccount` would crash when passed to `validateAndRefreshConnectedAccountAuthentication`.
Both guards follow the exact same pattern as the existing `!messageChannel` null check: track via monitoring service, return early. This ensures the error is observable (operators can query for `connected_account_not_found` events) while preventing the crash that blocks the entire messaging queue worker.
**Important**: This fix prevents the crash but does NOT restore sync for affected accounts. IMAP connected accounts that were skipped during the 1.20 data migration (because their `accountOwnerId` couldn't be resolved to a `userWorkspaceId`) still need to be manually migrated to the core schema. This requires running a data backfill operation — either re-running the upgrade command with fixes for the owner resolution, or manually inserting the missing rows into `core.connectedAccount`.
The #1 Open-Source CRM
🌐 Website · 📚 Documentation · Roadmap ·
Discord ·
Figma
Installation
See: 🚀 Self-hosting 🖥️ Local Setup
Why Twenty
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 Jotai, Linaria 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!




