symfony/translation · error · InvalidArgumentException

Invalid domain: " ".

Error message

Invalid domain: "%s".

What it means

Generic argument guard in AbstractOperation::getMessages(): the requested $domain string is not present in the cached list of domains collected from the source and target catalogues (including ICU domains with the +intl-icu suffix). It fires for any typo or domain that has no messages in either catalogue, as an InvalidArgumentException.

Solutions

  1. Call AbstractOperation::getDomains() (or catalogue->getDomains()) first and pick the domain from that list.
  2. Fix the domain name typo — domains must match exactly what the catalogues contain, e.g. 'messages' or 'validators'.
  3. Check for the ICU variant: domains may exist both as 'messages' and 'messages+intl-icu'; use the exact variant stored in the catalogue.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at Catalogue/AbstractOperation.php:98 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of symfony/translation@ae9e8a51bc (2026-09-15). Data as JSON: /api/errors/63dcd890ba638d04. Report an issue: GitHub.

Appendix: source

Thrown at Catalogue/AbstractOperation.php:98

                foreach ($catalogue->getDomains() as $domain) {
                    $domains[$domain] = $domain;

                    if ($catalogue->all($domainIcu = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX)) {
                        $domains[$domainIcu] = $domainIcu;
                    }
                }
            }

            $this->domains = array_values($domains);
        }

        return $this->domains;
    }

    public function getMessages(string $domain): array
    {
        if (!\in_array($domain, $this->getDomains(), true)) {
            throw new InvalidArgumentException(\sprintf('Invalid domain: "%s".', $domain));
        }

        if (!isset($this->messages[$domain][self::ALL_BATCH])) {
            $this->processDomain($domain);
        }

        return $this->messages[$domain][self::ALL_BATCH];
    }

    public function getNewMessages(string $domain): array
    {
        if (!\in_array($domain, $this->getDomains(), true)) {
            throw new InvalidArgumentException(\sprintf('Invalid domain: "%s".', $domain));
        }

        if (!isset($this->messages[$domain][self::NEW_BATCH])) {
            $this->processDomain($domain);
        }

View on GitHub (pinned to ae9e8a51bc)