Issue Description
Automatic DNS management with the Mythic Beasts provider fails when publishing the full record set for a domain. Most record updates fail with HTTP 429 “Rate limited” and the first few fail with HTTP 400 {“error”: “invalid_request”}. The API key itself is valid and works correctly when tested manually from the same host.
The likely cause is a race in token acquisition in src/providers/mythicbeasts.rs (dns-update). ensure_token() checks the cached token under the mutex, releases the lock, requests a new token from https://auth.mythic-beasts.com/login and only then stores it. When the DnsManagement task updates many record sets concurrently on a cold cache, every call misses the cache and performs its own login at the same moment. Around 18 simultaneous logins appear to trip Mythic Beasts’ rate limiter. The 400 invalid_request responses are in the OAuth2 error format returned by the auth service and appear to come from the same burst, as the credentials are valid. resolve_zone() follows the same check-then-fetch pattern and may add to the burst.
Expected Behavior
All records in the domain’s publishRecords set are published to the Mythic Beasts zone and the DnsManagement task completes successfully.
Actual Behavior
The DnsManagement task fails. Of the 18 record sets attempted, 3 fail with HTTP 400 {“error”: “invalid_request”} and 15 fail with HTTP 429 {“message”: “Rate limited”}. No records are published.
Reproduction Steps
- Create a DnsServer of type MythicBeasts with a valid DNS API v2 key ID and secret.
- Create a Domain with dnsManagement set to Automatic, dnsServerId pointing to that DnsServer and the default publishRecords set.
- Allow the initial DnsManagement task to run.
- Check Management › Tasks › Failed or the log for the task result.
Relevant Log Output
Note - domain anonymised.
Level: Warning
Event: Task failed during processing
id = 334180496651561472, details = “DnsManagement”, reason = “Failed to set DNS RRSet for _caldavs._tcp.example.com./SRV: Failed to set DNS RRSet: API error: BadRequest {“error”: “invalid_request”}; Failed to set DNS RRSet for _jmap._tcp.example.com./SRV: Failed to set DNS RRSet: API error: BadRequest {“error”: “invalid_request”}; Failed to set DNS RRSet for autodiscover.example.com./CNAME: Failed to set DNS RRSet: API error: BadRequest {“error”: “invalid_request”}; Failed to set DNS RRSet for autoconfig.example.com./CNAME: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for example.com./MX: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for _submissions._tcp.example.com./SRV: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for _ua-auto-config.example.com./TXT: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for _mta-sts.example.com./TXT: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for _imaps._tcp.example.com./SRV: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for v1-rsa-20261004._domainkey.example.com./TXT: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for _pop3s._tcp.example.com./SRV: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for _carddavs._tcp.example.com./SRV: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for example.com./CAA: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for mta-sts.example.com./CNAME: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for ua-auto-config.example.com./CNAME: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for v1-ed25519-20261004._domainkey.example.com./TXT: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for _validation-persist.example.com./TXT: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}; Failed to set DNS RRSet for example.com./TXT: Failed to set DNS RRSet: API error: HTTP 429: {“message”: “Rate limited”}”
Stalwart Version
v0.16.x
Installation Method
Binary (Linux)
Database Backend
RocksDB
Blob Storage
Filesystem
Search Engine
Internal
Directory Backend
Internal
Additional Context
Credentials verified from the Stalwart host:
- POST to https://auth.mythic-beasts.com/login with grant_type=client_credentials returned a valid bearer token.
- GET https://api.mythic-beasts.com/dns/v2/zones with that token returned the zone list including example.com.
So the key, its permissions and the network path are all fine.
References:
- Mythic Beasts auth service: Auth service - Mythic Beasts
- Mythic Beasts DNS API v2: Primary DNS API v2 - Mythic Beasts
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