octobercms/october · error · ApplicationException

Cannot find a dashboard with the specified slug: ":slug".

Error message

Cannot find a dashboard with the specified slug: ":slug".

What it means

Thrown by Dashboard::updateDashboard when saving a dashboard definition: it lowercases the slug, scopes the query with applyOwner($owner) and looks for a row where code = slug. If no matching row exists for that owner, an ApplicationException aborts the save. The dashboard record is normally created beforehand by Dashboard::syncAll, so this error means the record was never synced, was deleted, or the slug does not match the stored code.

Source

Thrown at modules/dashboard/models/Dashboard.php:144

     */
    public function resetDashboardPreference($owner, $field)
    {
        UserPreference::forUser()->reset($this->getUserPreferencesKey($owner, $field));
    }

    /**
     * updateDashboard
     */
    public function updateDashboard($owner, $field, $definition)
    {
        $field = strtolower($field);
        if (!strlen($field)) {
            throw new SystemException('Slug must not be empty');
        }

        $dashboard = self::applyOwner($owner)->where('code', $field)->first();
        if (!$dashboard) {
            throw new ApplicationException(
                __("Cannot find a dashboard with the specified slug: \":slug\".", ['slug' => $field])
            );
        }

        $dashboard->is_custom = true;
        $dashboard->definition = $definition;
        $dashboard->save();
    }

    /**
     * scopeListDashboards
     */
    public function scopeListDashboards($query, $owner)
    {
        $dashboards = $query->applyOwner($owner)->with('roles')->get();

        $user = BackendAuth::user();
        $userRoleId = $user?->role_id;

View on GitHub (pinned to b608633a7e)

Solutions

  1. Make sure the dashboard definition exists for the owner before saving: run/check Dashboard::syncAll($owner, $definitions) so a row with that code is created.
  2. Verify the slug matches the stored code column exactly (updateDashboard compares after strtolower(), so the stored code must survive lowercasing).
  3. Confirm the $owner argument is the same value used when the dashboard was created (applyOwner filters by it).
  4. Wrap the call in a try/catch for ApplicationException and either create the dashboard or show a friendly validation message instead of a 500.

Example fix

// before
Dashboard::updateDashboard($owner, $slug, $definition);

// after - ensure the record exists, mirroring the model's own lookup
$slug = strtolower(trim($slug));
if (!Dashboard::applyOwner($owner)->where('code', $slug)->exists()) {
    throw new ValidationException(['slug' => "Unknown dashboard slug: {$slug}"]);
}
Dashboard::updateDashboard($owner, $slug, $definition);
Defensive patterns

Strategy: validation

Validate before calling

use Dashboard\Models\Dashboard;

$slug = strtolower(trim($slug));
$exists = Dashboard::applyOwner($owner)->where('code', $slug)->exists();
if (!$exists) {
    throw new \ValidationException(['slug' => "Dashboard '{$slug}' not found for this owner"]);
}

Try / catch

try {
    Dashboard::updateDashboard($owner, $slug, $definition);
} catch (\ApplicationException $e) {
    // slug unknown for this owner: sync definitions or report to the user
    \Flash::error($e->getMessage());
}

Prevention

When it happens

Trigger: Calling Dashboard::updateDashboard($owner, $slug, $definition) with a slug that has no row in dashboards for that owner; saving dashboard customizations in the backend before syncAll has run for the owner; passing a slug whose stored code differs after strtolower() (stored code has uppercase or whitespace); the record was deleted directly in the database.

Common situations: A plugin defines dashboards in its plugin registration but the user saves a dashboard before the definitions were synced to the database; dashboards tables were partially migrated or pruned; the slug is passed with different casing or leading/trailing whitespace; two owners share a slug but applyOwner scopes to only one.

Related errors


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/da62be407a228949. Report an issue: GitHub.