IAV-1273/feat: delete source AgentIntegration after successful replication for channel-type credentials
Summary
Channel-type integrations (Telegram, WhatsApp, Facebook Messenger, Instagram Header Auth)
can only be active in one N8N instance at a time. Previously, replication would create a new
AgentIntegration without removing the old one, leaving orphaned integrations in the database.
Changes
- After a successful replication, the source
AgentIntegrationis now deleted only for channel-type credential types (NON_REPLICABLE_CREDENTIAL_TYPES) - Secondary credentials of the source integration are deleted first to respect FK constraints
- Non-channel integrations (
SLACK,GMAIL, etc.) are unaffected — their source is preserved - Added a null check on the source integration DTO before the connectivity check, raising
NO_SOURCE_INTEGRATION_FOUNDinstead of an NPE - Updated the replication blocked error message to clearly explain that the integration must
be disconnected (
connected=false) before replication is allowed
Transactional Safety
All operations (create new + delete old) run inside the same @Transactional boundary.
| Scenario | Behavior |
|---|---|
| Replication succeeds | New integration created |
| Failure during credential replication | Full rollback — source preserved |
| Failure during new integration save | Full rollback — source preserved |
| Failure during source deletion | Full rollback — neither persisted |
Scope
| Credential type | Source deleted after replication |
|---|---|
TELEGRAM, WHATSAPP, FACEBOOK_MESSENGER, INSTAGRAM_HEADER_AUTH
|
|
| All other types |
|