coollabsio/coolify · warning · InvalidArgumentException
{$error}
Error message
{$error} What it means
When saving custom domains for a compose-based PR preview, each submitted domain is run through ValidationPatterns::validateApplicationDomains(); every violation message is thrown verbatim as an InvalidArgumentException. The message you see is dynamic - it is the domain validation error text (invalid FQDN, bad scheme, disallowed characters, etc.), not a fixed string.
Source
Thrown at app/Livewire/Project/Application/PreviewsCompose.php:73
$applicationDomains = json_decode($this->preview->application->docker_compose_domains ?: '[]', true) ?: [];
$domain_string = getComposeServiceDomainString($applicationDomains, (string) $this->serviceName);
// If no domain is set in the main application, generate a default domain
if (empty($domain_string)) {
$server = $this->preview->application->destination->server;
$template = $this->preview->application->preview_url_template;
$random = new_public_id();
// Generate a unique domain like main app services do
$generated_fqdn = generateUrl(server: $server, random: $random);
$preview_fqdn = str_replace('{{random}}', $random, $template);
$preview_fqdn = str_replace('{{domain}}', str($generated_fqdn)->after('://'), $preview_fqdn);
$preview_fqdn = str_replace('{{pr_id}}', $this->preview->pull_request_id, $preview_fqdn);
$preview_fqdn = str($generated_fqdn)->before('://').'://'.$preview_fqdn;
} else {
foreach (ValidationPatterns::validateApplicationDomains($domain_string) as $error) {
throw new \InvalidArgumentException($error);
}
// Use the existing domain from the main application
// Handle multiple domains separated by commas
$domain_list = ValidationPatterns::applicationDomainList($domain_string);
$preview_fqdns = [];
$template = $this->preview->application->preview_url_template;
$random = new_public_id();
foreach ($domain_list as $single_domain) {
$single_domain = trim($single_domain);
if (empty($single_domain)) {
continue;
}
$url = Url::fromString($single_domain);
$host = $url->getHost();
$schema = $url->getScheme();View on GitHub (pinned to 70b9acc424)
Solutions
- Match the format the main application domains use - scheme + valid hostname (see ValidationPatterns::applicationDomainRules())
- Separate multiple domains with commas, trim whitespace, and strip paths/ports/query strings
- If a generated preview URL is acceptable, leave the domain empty and let Coolify derive it from the preview URL template
Defensive patterns
Strategy: validation
Validate before calling
// validate before submitting the form, using the same rule set
use App\Support\ValidationPatterns;
$errors = ValidationPatterns::validateApplicationDomains($domainString);
if ($errors !== []) {
// show $errors inline; do not submit
} Type guard
function isValidApplicationDomain(string $domain): bool
{
return ValidationPatterns::validateApplicationDomains($domain) === [];
} Prevention
- Mirror the main application's domain format: scheme + hostname, comma-separated for multiple
- Trim whitespace and strip paths/ports before submitting
- Prefer the generated preview URL template over hand-typed domains when in doubt
When it happens
Trigger: Submitting a preview domain string that fails the domain rules: wrong format, missing or wrong scheme, invalid hostname characters, path or query segments, or an entry in the comma-separated list that is not a valid domain.
Common situations: Pasting full URLs with paths; trailing spaces or empty entries between commas; wildcards where not permitted; copy-pasting from a browser address bar; using a template placeholder that did not get substituted.
Related errors
- Preview not found
- Destination not found.
- Invalid Cron / Human expression
- $e->getMessage()
- Docker Compose file not found at: $workdir$composeFile (bran
AI-assisted analysis of coollabsio/coolify@70b9acc424 (2026-08-17).
Data as JSON: /api/errors/0e6cad2f7d30b90f.
Report an issue: GitHub.