Adding a tag to a domain that already has tags silently discards it (API returns 200 with empty body)
Contribution guidelines
- I've read the contribution guidelines and wholeheartedly agree
Checklist prior issue creation
- I understand that failure to follow below instructions may cause this issue to be closed.
- I understand that vague, incomplete or inaccurate information may cause this issue to be closed.
- I understand that this form is intended solely for reporting software bugs and not for support-related inquiries.
- I understand that all responses are voluntary and community-driven, and do not constitute commercial support.
- I confirm that I have reviewed previous issues to ensure this matter has not already been addressed.
- I confirm that my environment meets all prerequisite requirements as specified in the official documentation.
Description
A tag can only be added to a domain while that domain has no tags yet. Every later tag is silently discarded.
tags_domain has a unique key on (tag_name, domain). The tag widget in the UI keeps the full tag list in a hidden field and submits all tags on save, so saving a domain that already carries a tag re-inserts that tag:
The duplicate INSERT raises a PDO exception. Nothing catches it on the domain paths, so:
- the remaining (new) tags in the list are never inserted,
- the function returns without ever adding its
domain_modifiedsuccess message, - the API answers HTTP 200 with an empty body, and the UI reports nothing wrong.
The three tags_mailbox inserts already guard against exactly this with a try { ... } catch (Exception $e) {}, so mailbox tags are unaffected. The three tags_domain inserts (domain add, and both domain edit branches) have no such guard.
Steps to reproduce:
- Create a domain with no tags.
- Add a first tag and save — works.
- Add a second tag and save. The UI submits
["existing", "new"]. - Observe the new tag is not stored.
Via the API:
# domain has tag "alpha" already
curl -sS -H "X-API-Key: $API_KEY" -H "Content-Type: application/json" -X POST \
"$MAILCOW_URL/api/v1/edit/domain" \
--data '{"items":["example.test"],"attr":{"tags":["alpha","beta"]}}' -w '\nHTTP=%{http_code}\n'Observed:
HTTP=200with an empty response body, and beta missing from tags_domain.
Expected: an already assigned tag is skipped and beta is stored, as happens for mailbox tags.
A request that combines a description change with a duplicate tag shows the partial-failure clearly: the description is written (it happens before the tag loop) and the tags after the duplicate are not.
Logs:
N/A - the exception is not surfaced; the request ends with HTTP 200 and an empty body.Which branch are you using?
staging
Which architecture are you using?
x86_64
Operating System:
Debian GNU/Linux
Server/VM specifications:
N/A
Is Apparmor, SELinux or similar active?
no
Virtualization technology:
Docker
Docker version:
29.5.2
docker-compose version or docker compose version:
v2.40.3
mailcow version:
staging (f4961c40)
Reverse proxy:
none
Logs of git diff:
N/ADNS check:
N/ASource: mailcow/mailcow-dockerized