Domain not Usable after Migration

Issue Description

afert migration from 15.5 to 16.13 i cant change domain settings like automatic dns and acme.
i can’t even delete the domain i always receive the error “This item references another item that does not exist.”

Stalwart Version

v0.16.x

Installation Method

Binary (Linux)

Database Backend

RocksDB

Blob Storage

RocksDB

Search Engine

Internal

Directory Backend

Internal

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

This looks directly relevant. Let me check the UPGRADING doc’s section about dangling foreign keys and the snapshot doc’s static reference validation section for how to fix an existing broken domain.

Now I have enough to answer accurately.

The invalidForeignKey error on Domain means the Domain record references another object (e.g. a Tenant, AcmeProvider, DkimSignature, or Certificate) that no longer exists in the migrated database, typically because that referenced object was not created (or was skipped) during the migration apply. This is a known post-migration issue documented in the v0.16 upgrade guide’s troubleshooting section.

To fix it:

  1. Identify what the Domain references. Query it to see its fields:
stalwart-cli query Domain --where name=<domain> --fields id,name,memberTenantId,acmeProviderId,dkimSignatureId

Any field pointing to an id that doesn’t exist (check with stalwart-cli query <ReferencedType>) is the broken link.

  1. Since you can’t currently edit it (any update is also rejected because the same missing reference is re-validated), you generally have two options:
  • Clear/null out the broken reference field via stalwart-cli update Domain <id> --field <field>=null if the field accepts null, restoring the Domain to a consistent state, then re-add ACME/DKIM/etc. from the WebUI.
  • If the referenced object (e.g. Tenant, AcmeProvider, DkimSignature, Certificate) simply failed to get created during migration, recreate that missing object first (matching the original id/name from your v0.15 export), which resolves the dangling reference.
  1. Domain, Tenant, DkimSignature, and Certificate are safe to delete and recreate during recovery (unlike Account, which must never be deleted post-migration since it holds mailbox data). If the Domain itself is unrecoverable, you can delete just the Domain object (not the Account) and recreate it fresh, then reattach ACME/DKIM.

The upgrade guide’s “Recovering from a partial apply” and “Common questions” sections in UPGRADING/v0_16.md cover this exact class of error: stalwart/UPGRADING/v0_16.md at main · stalwartlabs/stalwart · GitHub

If you can share the specific fields returned by stalwart-cli query Domain --where name=<yourdomain> --fields id,name,memberTenantId,acmeProviderId,dkimSignatureId,certificateId I can help pinpoint which reference is dangling.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

i get this:

root@stalwart:~# stalwart-cli query domain --where name=xxx --fields id,name,memberTenantId,acmeProviderId,dkimSignatureId --url https://xxx--user admin@xxx–password xxx

error: unknown field: acmeProviderId

acme and dns wasn’t connected to the right tenant, but didn’t see an option in the ui for that.

Also the failer is not very helpful.