coollabsio/coolify · error · InvalidArgumentException

Unknown notification channel [{$channel}].

Error message

Unknown notification channel [{$channel}].

What it means

NotificationsController::channelConfig() is a PHP match over the channel string with arms for 'email', 'discord', 'slack', 'telegram', and 'webhook'; any other value falls into default and throws InvalidArgumentException('Unknown notification channel [...]'). The channel string comes from the {channel} route segment of the notifications API endpoints.

Source

Thrown at app/Http/Controllers/Api/NotificationsController.php:181

                    'webhook_enabled' => 'sometimes|boolean',
                    'webhook_url' => ['sometimes', 'nullable', 'string', new SafeWebhookUrl],
                    'deployment_success_webhook_notifications' => 'sometimes|boolean',
                    'deployment_failure_webhook_notifications' => 'sometimes|boolean',
                    'status_change_webhook_notifications' => 'sometimes|boolean',
                    'backup_success_webhook_notifications' => 'sometimes|boolean',
                    'backup_failure_webhook_notifications' => 'sometimes|boolean',
                    'scheduled_task_success_webhook_notifications' => 'sometimes|boolean',
                    'scheduled_task_failure_webhook_notifications' => 'sometimes|boolean',
                    'docker_cleanup_success_webhook_notifications' => 'sometimes|boolean',
                    'docker_cleanup_failure_webhook_notifications' => 'sometimes|boolean',
                    'server_disk_usage_webhook_notifications' => 'sometimes|boolean',
                    'server_reachable_webhook_notifications' => 'sometimes|boolean',
                    'server_unreachable_webhook_notifications' => 'sometimes|boolean',
                    'server_patch_webhook_notifications' => 'sometimes|boolean',
                    'traefik_outdated_webhook_notifications' => 'sometimes|boolean',
                ],
            ],
            default => throw new \InvalidArgumentException("Unknown notification channel [{$channel}]."),
        };
    }

    /**
     * @return list<string>
     */
    private function allowedFields(string $channel): array
    {
        $config = $this->channelConfig($channel);
        /** @var Model $model */
        $model = new $config['model'];

        return array_values(array_filter(
            $model->getFillable(),
            fn (string $field): bool => $field !== 'team_id'
        ));
    }

View on GitHub (pinned to 70b9acc424)

Solutions

  1. Use one of the supported lowercase channel names exactly: email, discord, slack, telegram, webhook.
  2. Check the route parameter for typos, capitalization, or trailing characters.
  3. If you extended Coolify with a new channel, add a match arm in channelConfig() plus the corresponding show/update routes and allowed fields.

Example fix

// before: unmatched channel falls through to the throw
$channel = $request->route('channel'); // 'teams'
$config = $this->channelConfig($channel);

// after: validate against the supported set first
$channel = strtolower(trim((string) $request->route('channel')));
if (! in_array($channel, ['email', 'discord', 'slack', 'telegram', 'webhook'], true)) {
    abort(404, "Unsupported notification channel '{$channel}'. Supported: email, discord, slack, telegram, webhook.");
}
$config = $this->channelConfig($channel);
Defensive patterns

Strategy: type-guard

Type guard

/** @param mixed $channel */
function isValidNotificationChannel($channel): bool
{
    return is_string($channel)
        && in_array(strtolower(trim($channel)), ['email', 'discord', 'slack', 'telegram', 'webhook'], true);
}

Try / catch

try {
    $config = $this->channelConfig($channel);
} catch (\InvalidArgumentException $e) {
    if (str_starts_with($e->getMessage(), 'Unknown notification channel')) {
        abort(404, 'Supported channels: email, discord, slack, telegram, webhook.');
    }
    throw $e;
}

Prevention

When it happens

Trigger: Calling /api/v1/notifications/{channel} or the update endpoint with a misspelled or unregistered channel (e.g. 'Email', 'teams', 'smtp', 'webhooks'); passing a channel that exists in the UI but was never added to this match statement.

Common situations: API consumers guessing endpoint names; case mismatches ('Slack' vs 'slack'); trailing whitespace or slashes in the URL segment; forks adding a new channel type in the frontend but not in channelConfig().

Related errors


AI-assisted analysis of coollabsio/coolify@70b9acc424 (2026-08-17). Data as JSON: /api/errors/da81192d49538f09. Report an issue: GitHub.