1.0 Migration from v.0.16.27 ACME provider couldn't be migrated

Issue Description

When running die migration, the ACME provider couldn’t be migrated.
I worked around this issue with removing the provider association for all domains.
Migration worked but adding the provider back or creating a new one to add to a domain returns an error.

Expected Behavior

I can successfully add the newly created or migrated ACME provider to a domain.

Actual Behavior

When saving the domain with the old migrated or a newly created ACME provider this error is shown in the UI:
“This item references another item that does not exist.”

Reproduction Steps

  1. Migrate a v0.16.27 instance with configured ACME setup.

Relevant Log Output

Ui error:
This item references another item that does not exist.

Trace Logs:
2026-10-26T20:43:49Z TRACE HTTP request body (http.request-body) listenerId = “https”, localPort = 443, remoteIp = , remotePort = 48968, headers = [[“host”, “”], [“user-agent”, “Mozilla/5.0 (X11; Linux x86_64; rv:158.0) Gecko/20100101 Firefox/158.0”], [“accept”, “/”], [“accept-language”, “en-GB,en;q=0.9”], [“accept-encoding”, “gzip, deflate, br, zstd”], [“referer”, “https:///admin/Management/x:Domain/d”], [“authorization”, “”], [“content-type”, “application/json”], [“content-length”, “401”], [“origin”, “https://”], [“sec-gpc”, “1”], [“connection”, “keep-alive”], [“cookie”, “”], [“sec-fetch-dest”, “empty”], [“sec-fetch-mode”, “cors”], [“sec-fetch-site”, “same-origin”], [“priority”, “u=4”]], contents = “{"using":["urn:ietf:params:jmap:core","urn:stalwart:jmap","urn:ietf:params:jmap:blob","urn:ietf:params:jmap:mail","urn:ietf:params:jmap:calendars","urn:ietf:params:jmap:contacts","urn:ietf:params:jmap:principals","urn:ietf:params:jmap:sieve","urn:ietf:params:jmap:vacationresponse"],"methodCalls":[["x:AcmeProvider/get",{"accountId":"b","ids":[""],"properties":["id","description"]},"0"]]}”, size = 401
2026-10-26T20:43:49Z DEBUG JMAP method call (jmap.method-call) listenerId = “https”, localPort = 443, remoteIp = , remotePort = 48968, command = “x:AcmeProvider/get”, accountId = 1, elapsed = 0ms
2026-10-26T20:43:49Z TRACE HTTP response body (http.response-body) listenerId = “https”, localPort = 443, remoteIp = , remotePort = 48968, contents = “{"methodResponses":[["x:AcmeProvider/get",{"accountId":"b","list":[{"description":"Let’s Encrypt Live","id":""}],"notFound":},"0"]],"sessionState":""}”, code = 200, size = 172

Migration logs when running concurrently, but another issue:

2026-10-26T19:25:11.452840Z INFO migrate::commands::run: run state=/var/lib/stalwart-migrate/state.sqlite source=/etc/stalwart/config-0.16.json target=/etc/stalwart/config.json categories=settings,principals,mail,calendars,contacts,files,sieve,identities,push_subscriptions,spam_samples,reports,archive,spam_model,queue,tasks,telemetry blob_mode=Copy edition=“enterprise” concurrency=8
2026-10-26T19:25:12.484944Z INFO migrate::orchestrator::account: account pass started accounts=2 removed=0
2026-10-26T19:25:26.455363Z INFO progress: progress run_id=3 objects_written=0 emails_written=0 bytes_written=0 objects_skipped=0 objects_deleted=0 log_rows=0 blobs_copied=0 blob_bytes=0 registry_written=0 registry_dropped=0 registry_deleted=0 accounts_full=0 accounts_delta=0 accounts_unchanged=0 accounts_failed=0 accounts_wiped=0 accounts_removed=0 global_records=0 global_deleted=0 issues=1 errors=0
2026-10-26T19:25:41.454879Z INFO progress: progress run_id=3 objects_written=0 emails_written=0 bytes_written=0 objects_skipped=0 objects_deleted=0 log_rows=0 blobs_copied=0 blob_bytes=0 registry_written=0 registry_dropped=0 registry_deleted=0 accounts_full=0 accounts_delta=0 accounts_unchanged=0 accounts_failed=0 accounts_wiped=0 accounts_removed=0 global_records=0 global_deleted=0 issues=1 errors=0
2026-10-26T19:25:46.205636Z ERROR migrate::orchestrator::account: account failed account_id=2 error=transient error: Authentication error (auth.error): details = Account not found., accountId = 2, causedBy = vendor/v1/crates/common/src/cache/principals.rs:381
2026-10-26T19:25:51.881325Z ERROR migrate::orchestrator::account: account failed account_id=1 error=transient error: Authentication error (auth.error): details = Account not found., accountId = 1, causedBy = vendor/v1/crates/common/src/cache/principals.rs:381
2026-10-26T19:25:51.889029Z ERROR migrate::orchestrator: run finished with failed accounts failed_accounts=2
2026-10-26T19:25:51.891288Z INFO migrate::orchestrator: run finished run_id=3 status=failed stats={“accounts_delta”:0,“accounts_failed”:2,“accounts_full”:0,“accounts_removed”:0,“accounts_unchanged”:0,“accounts_wiped”:0,“blob_bytes”:0,“blobs_copied”:0,“bytes_written”:0,“emails_written”:0,“errors”:2,“global_deleted”:0,“global_records”:0,“issues”:3,“log_rows”:0,“objects_deleted”:0,“objects_skipped”:0,“objects_written”:0,“registry_deleted”:0,“registry_dropped”:0,“registry_written”:0}
run 3: failed ({“accounts_delta”:0,“accounts_failed”:2,“accounts_full”:0,“accounts_removed”:0,“accounts_unchanged”:0,“accounts_wiped”:0,“blob_bytes”:0,“blobs_copied”:0,“bytes_written”:0,“emails_written”:0,“errors”:2,“global_deleted”:0,“global_records”:0,“issues”:3,“log_rows”:0,“objects_deleted”:0,“objects_skipped”:0,“objects_written”:0,“registry_deleted”:0,“registry_dropped”:0,“registry_written”:0})

State database: /var/lib/stalwart-migrate/state.sqlite
tool_version 1.0.0
edition enterprise
source_def_hash 3f4655519a9b20ff8f7a8ac5488987b8
target_def_hash 79d2ab5360c06ea5f656e4f1a3b59dd8
target_schema_version 7
categories settings,principals,mail,calendars,contacts,files,sieve,identities,push_subscriptions,spam_samples,reports,archive,spam_model,queue,tasks,telemetry
created_at 2026-10-26T19:18:45Z
source_store directory /opt/stalwart/data
target_claim 64aa033ce306b802d6b58dc6ff961f31
claim_generation 20d46fe7cad9c82927398267e6c32d01
claim_generation_pending 20d46fe7cad9c82927398267e6c32d01
final_done not done

Accounts: 2
error 2

Accounts in error:
1 attempts 3 transient error: Authentication error (auth.error): details = Account not found., accountId = 1, causedBy = vendor/v1/crates/common/src/cache/principals.rs:381
2 attempts 3 transient error: Authentication error (auth.error): details = Account not found., accountId = 2, causedBy = vendor/v1/crates/common/src/cache/principals.rs:381

Recent runs:
#3 incremental failed started 2026-10-26T19:25:11Z took 40s
accounts_failed=2, errors=2, issues=3
#2 incremental failed started 2026-10-26T19:22:54Z took 38s
accounts_failed=2, errors=2, issues=3
#1 incremental failed started 2026-10-26T19:18:45Z took 44s
accounts_failed=2, blob_bytes=4559409, blobs_copied=72, errors=17, global_records=34148, issues=93, registry_dropped=12, registry_written=4256

Reports in the latest run:
error failed 2
warning dropped 1

Reports in all runs:
error failed 20
error skipped 1
info changed 15
warning dropped 63

run severity category account object id message
2 error failed 1 - - transient error: Authentication error (auth.error): details = Account not found., accountId = 1, causedBy = vendor/v1/crates/common/src/cache/principals.rs:381
2 error failed 2 - - transient error: Authentication error (auth.error): details = Account not found., accountId = 2, causedBy = vendor/v1/crates/common/src/cache/principals.rs:381
2 rows

Migration logs:

info: x:AcmeProvider/iq23htewaaqa description: acme_description: v0.16 computed the description from the directory URL and the account; v1 stores it
warning: x:AcmeProvider/iq23htewaaqa maxRetries: dropped (no equivalent in the target version), was 10

1 info changed - AcmeProvider 307264283016692224 info: x:AcmeProvider/iq23htewaaqa description: acme_description: v0.16 computed t
he description from the directory URL and the account; v1 stores it
1 warning dropped - AcmeProvider 307264283016692224 warning: x:AcmeProvider/iq23htewaaqa maxRetries: dropped (no equivalent in the ta
rget version), was 10
1 error failed - x:Domain 1 rejected by v1: Invalid foreign key: AcmeProvider with id iq23htewaaqa
1 error failed - x:Domain 2 rejected by v1: Invalid foreign key: AcmeProvider with id iq23htewaaqa
1 error failed - x:Domain 3 rejected by v1: Invalid foreign key: AcmeProvider with id iq23htewaaqa
[root@mail opt]# sudo grep -i iq23htewaaqa $STATE/logs/run-1793042325-63450.log | head

Stalwart Version

v1.x

Installation Method

Binary (Linux)

Database Backend

RocksDB

Blob Storage

RocksDB

Search Engine

Internal

Directory Backend

Internal

Additional Context

Sorry if I might mixed up some logs. I did troubleshoot quite a bit and haven’t sorted the saved output.

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

I couldn’t find a documented cause for this, so I can only tell you what the source shows.

  • What the error means: The message “This item references another item that does not exist” is the UI text for the server’s InvalidForeignKey result. When you save a Domain, the registry write path checks that every referenced object, here the AcmeProvider in certificateManagement, exists in the registry index. If the index key is missing, the write is rejected (crates/store/src/registry/write.rs). The migration tool’s “Invalid foreign key: AcmeProvider with id iq23htewaaqa” on Domains 1, 2 and 3 is the same check.
  • Your trace: x:AcmeProvider/get does return the provider, so the object is readable. But I couldn’t tell from the source why the foreign-key check still fails for a provider that exists, including a newly created one. The check for that provider’s index entry could be failing, but I haven’t confirmed it.
  • Migration order: The migrator reported the AcmeProvider as written, with a changed description and a dropped maxRetries. The Domains were rejected anyway, which may point to an ordering or index problem in the migration run.
  • Failed accounts: Run 3 also failed both accounts with “Account not found”. That looks like a separate problem. The migration is therefore incomplete, and the target may be in a partial state.

This isn’t covered in the current docs. A community member or staff member will follow up.

It would help to know whether the Domain save still fails when certificateManagement is set to Manual. It would also help to see the full x:Domain/set request and response that return the error. Please post those.

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

Setting certificateManagement to manual does not fail on save.

The x:Domain/set request:

2026-10-26T20:43:49Z TRACE HTTP request body (http.request-body) listenerId = “https”, localPort = 443, remoteIp = , remotePort = 48968, headers = [[“host”, “”], [“user-agent”, “Mozilla/5.0 (X11; Linux x86_64; rv:158.0) Gecko/20100101 Firefox/158.0”], [“accept”, “/”], [“accept-language”, “en-GB,en;q=0.9”], [“accept-encoding”, “gzip, deflate, br, zstd”], [“referer”, “https:///admin/Management/x:Domain/d”], [“authorization”, “”], [“content-type”, “application/json”], [“content-length”, “435”], [“origin”, “”], [“sec-gpc”, “1”], [“connection”, “keep-alive”], [“cookie”, “”], [“sec-fetch-dest”, “empty”], [“sec-fetch-mode”, “cors”], [“sec-fetch-site”, “same-origin”], [“priority”, “u=0”]], contents = “{“using”:[“urn:ietf:params:jmap:core”,“urn:stalwart:jmap”,“urn:ietf:params:jmap:blob”,“urn:ietf:params:jmap:mail”,“urn:ietf:params:jmap:calendars”,“urn:ietf:params:jmap:contacts”,“urn:ietf:params:jmap:principals”,“urn:ietf:params:jmap:sieve”,“urn:ietf:params:jmap:vacationresponse”],“methodCalls”:[[“x:Domain/set”,{“accountId”:“b”,“update”:{“d”:{“certificateManagement”:{”@type":“Automatic”,“acmeProviderId”:“jlooy1tuaaaa”}}}},“set”]]}", size = 435

The x:Domain/set response:

2026-10-26T20:43:49Z TRACE HTTP response body (http.response-body) listenerId = “https”, localPort = 443, remoteIp = , remotePort = 48968, contents = “{“methodResponses”:[[“x:Domain/set”,{“accountId”:“b”,“notUpdated”:{“d”:{“type”:“invalidForeignKey”,“objectId”:{“object”:“AcmeProvider”,“id”:“jlooy1tuaaaa”}}}},“set”]],“sessionState”:“79e358cc”}”, code = 200, size = 193

This has been fixed. Please try again with stalwart-migrate 1.0.1 which is being compiled now.

I did a rollback and migrated everything again. No reported errors regarding the ACME settings. Just one for a SpamTrainingSample which I accepted.

Unfortunately, after migrating back and forth, the error still persists.
I do not need to keep the old ACME prover settings but even newly created ones do not work and report the same error.

For some more troubleshooting I threw every log so far in claude and got a hint I haven’t thought about, jet.

The domains are all associated with a tenant. The ACME providers are not, because I prefer it be the same for all.

When adding the same tenant I used for one of my domains to the ACME provider, I can successfully add the provider to that domain but not to others anymore which is expected.

The behavior when setting a tenant for an ACME provider is fine, but the error message is misleading and should be more precise or even better: the ACME provider shouldn’t be selectable for a domain if a different tenant is set.

On v0.16.x I could add tenants to domains and use ACME providers without explicit tenant on all of them. This seems to not work anymore.

That’s the cause. In 1.0 an object that belongs to a tenant can only reference objects of the same tenant, and that includes a domain’s ACME provider. A provider with no tenant sits outside every tenant, so none of your tenants’ domains can use it. Domains without a tenant can still use it.

I should have been clearer in my last reply: what 1.0.1 fixed is that the migration no longer fails on those domains. It switches them to manual certificate management and reports it, which is why the ACME errors went away but the domains didn’t keep their provider.

To get automatic certificates back, create one ACME provider per tenant with that tenant set (same Let’s Encrypt settings each time), then pick it under each domain’s certificate management.

The picker shouldn’t offer providers a domain can’t use, and “references another item that does not exist” is misleading in this case. I’ve passed both on.

ACME providers being tenant-scoped is intentional in 1.0: a domain that belongs to a tenant can only use a provider assigned to that same tenant. So for your setup, the options are one provider per tenant, or leaving the domains without a tenant if they don’t need one.

Both of the problems you pointed out are fixed and will ship in the next weekly release:

  • On a domain with a tenant, the ACME provider picker (and the other pickers for tenant-scoped objects like DNS servers and directories) now only lists objects from that tenant.
  • Saving with a provider from another tenant, or one with no tenant, now explains why it was rejected, e.g. “AcmeProvider with id … is not assigned to the same tenant as this object.”, in place of the misleading “references another item that does not exist”.