octobercms/october · error · October\Rain\Exception\ValidationException
Unable to delete site group because it is being used by…
Error message
Unable to delete site group because it is being used by existing site definitions (:count).
What it means
Model event guard in SiteGroup::beforeDelete: the group still has associated site definitions, so deleting it would orphan those sites. The user must reassign or delete the :count sites in the group before removing the group.
Solutions
- Move or delete the site definitions assigned to the group first
- Reassign the sites to another group before deleting
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/system/models/SiteGroup.php:67 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/7e0c9b23362f3287.
Report an issue: GitHub.
Appendix: source
Thrown at modules/system/models/SiteGroup.php:67
public static function syncDefaultGroup()
{
if (static::count() > 0) {
return;
}
static::create([
'name' => 'Default',
'code' => 'default',
]);
}
/**
* beforeDelete
*/
public function beforeDelete()
{
if (($count = $this->sites()->count()) > 0) {
throw new ValidationException(['name' => __("Unable to delete site group because it is being used by existing site definitions (:count).", ['count' => $count])]);
}
}
/**
* afterDelete
*/
public function afterDelete()
{
PluginSiteGroup::where('site_group_id', $this->id)->delete();
Site::resetCache();
}
/**
* afterSave
*/
public function afterSave()
{View on GitHub (pinned to b608633a7e)