{"record":{"id":"da62be407a228949","repo":"octobercms/october","slug":"cannot-find-a-dashboard-with-the-specified-slug","errorCode":null,"errorMessage":"Cannot find a dashboard with the specified slug: \":slug\".","messagePattern":"Cannot find a dashboard with the specified slug: \":slug\"\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/dashboard/models/Dashboard.php","lineNumber":144,"sourceCode":"     */\n    public function resetDashboardPreference($owner, $field)\n    {\n        UserPreference::forUser()->reset($this->getUserPreferencesKey($owner, $field));\n    }\n\n    /**\n     * updateDashboard\n     */\n    public function updateDashboard($owner, $field, $definition)\n    {\n        $field = strtolower($field);\n        if (!strlen($field)) {\n            throw new SystemException('Slug must not be empty');\n        }\n\n        $dashboard = self::applyOwner($owner)->where('code', $field)->first();\n        if (!$dashboard) {\n            throw new ApplicationException(\n                __(\"Cannot find a dashboard with the specified slug: \\\":slug\\\".\", ['slug' => $field])\n            );\n        }\n\n        $dashboard->is_custom = true;\n        $dashboard->definition = $definition;\n        $dashboard->save();\n    }\n\n    /**\n     * scopeListDashboards\n     */\n    public function scopeListDashboards($query, $owner)\n    {\n        $dashboards = $query->applyOwner($owner)->with('roles')->get();\n\n        $user = BackendAuth::user();\n        $userRoleId = $user?->role_id;","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/dashboard/models/Dashboard.php#L126-L162","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Verify the slug matches the stored code column exactly (updateDashboard compares after strtolower(), so the stored code must survive lowercasing).","Confirm the $owner argument is the same value used when the dashboard was created (applyOwner filters by it).","Wrap the call in a try/catch for ApplicationException and either create the dashboard or show a friendly validation message instead of a 500."],"exampleFix":"// before\nDashboard::updateDashboard($owner, $slug, $definition);\n\n// after - ensure the record exists, mirroring the model's own lookup\n$slug = strtolower(trim($slug));\nif (!Dashboard::applyOwner($owner)->where('code', $slug)->exists()) {\n    throw new ValidationException(['slug' => \"Unknown dashboard slug: {$slug}\"]);\n}\nDashboard::updateDashboard($owner, $slug, $definition);","handlingStrategy":"validation","validationCode":"use Dashboard\\Models\\Dashboard;\n\n$slug = strtolower(trim($slug));\n$exists = Dashboard::applyOwner($owner)->where('code', $slug)->exists();\nif (!$exists) {\n    throw new \\ValidationException(['slug' => \"Dashboard '{$slug}' not found for this owner\"]);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Dashboard::updateDashboard($owner, $slug, $definition);\n} catch (\\ApplicationException $e) {\n    // slug unknown for this owner: sync definitions or report to the user\n    \\Flash::error($e->getMessage());\n}","preventionTips":["Run Dashboard::syncAll($owner, $definitions) during plugin boot or migration so rows exist before the UI can save.","Always normalize slugs with strtolower(trim($slug)) before comparing or saving.","Never delete dashboards rows without updating dependent saved preferences."],"tags":["dashboard","database","slug","record-not-found"],"backgroundTag":"record-not-found","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}