{"record":{"id":"e6cfad68f54bc0da","repo":"cakephp/cakephp","slug":"no-crumb-matching-s-could-be-found","errorCode":null,"errorMessage":"No crumb matching `%s` could be found.","messagePattern":"No crumb matching `(.+?)` could be found\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"warning","filePath":"src/View/Helper/BreadcrumbsHelper.php","lineNumber":250,"sourceCode":"     * @param array<string, mixed> $options Array of options. These options will be used as HTML attributes the crumb will\n     * be rendered in (a <li> tag by default). It accepts two special keys:\n     *\n     * - *innerAttrs*: An array that allows you to define attributes for the inner element of the crumb (by default, to\n     *   the link)\n     * - *templateVars*: Specific template vars in case you override the templates provided.\n     * @return $this\n     * @throws \\LogicException In case the matching crumb can not be found\n     */\n    public function insertBefore(\n        string $matchingTitle,\n        string $title,\n        array|string|null $url = null,\n        array $options = [],\n    ) {\n        $key = $this->findCrumb($matchingTitle);\n\n        if ($key === null) {\n            throw new LogicException(sprintf('No crumb matching `%s` could be found.', $matchingTitle));\n        }\n\n        return $this->insertAt($key, $title, $url, $options);\n    }\n\n    /**\n     * Insert a crumb after the first matching crumb with the specified title.\n     *\n     * Finds the index of the first crumb that matches the provided class,\n     * and inserts the supplied callable before it.\n     *\n     * @param string $matchingTitle The title of the crumb you want to insert this one after.\n     * @param string $title Title of the crumb.\n     * @param array|string|null $url URL of the crumb. Either a string, an array of route params to pass to\n     * Url::build() or null / empty if the crumb does not have a link.\n     * @param array<string, mixed> $options Array of options. These options will be used as HTML attributes the crumb will\n     * be rendered in (a <li> tag by default). It accepts two special keys:\n     *","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/cakephp/cakephp/blob/1128eba9b09f1946df684811350e26f2cef68fac/src/View/Helper/BreadcrumbsHelper.php#L232-L268","documentation":"BreadcrumbsHelper::insertBefore() searches the current crumb list for the given matching URL/text and throws a LogicException when no crumb matches, because insertion is defined relative to an existing crumb. The faulting input is the $matching argument that found no crumb.","triggerScenarios":"$breadcrumbs->insertBefore('Dashboard', 'Sub', '/') when no crumb titled 'Dashboard' was added — titles are compared exactly, so case or whitespace differences also fail.","commonSituations":"Inserting relative to a crumb added in a parent layout/element that hasn't run yet; renaming a crumb title upstream; duplicated partial templates with divergent titles.","solutions":["Ensure the reference crumb is added (add()) before insertBefore() is called.","Match the title exactly (case/whitespace) with an existing crumb.","Check findCrumb()/getCrumbs() first and fall back to add() when the anchor is absent."],"exampleFix":"// before\n$breadcrumbs->insertBefore('Dashbaord', 'Reports', ['action' => 'reports']); // typo\n// after\n$breadcrumbs->insertBefore('Dashboard', 'Reports', ['action' => 'reports']);","handlingStrategy":"try-catch","validationCode":"if ($breadcrumbs->findCrumb($matchingTitle) === null) {\n    $breadcrumbs->add($matchingTitle, '/');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $breadcrumbs->insertBefore($anchor, $title, $url);\n} catch (\\LogicException $e) {\n    $breadcrumbs->add($title, $url);\n}","preventionTips":["Add the anchor crumb before relative inserts.","Use the exact same string (or the same translation call) for anchor titles.","Centralize breadcrumb titles in constants to avoid divergence."],"tags":["cakephp","breadcrumbs","view-helper"],"backgroundTag":"record-not-found","analyzedSha":"1128eba9b09f1946df684811350e26f2cef68fac","analyzedAt":"2026-09-12T12:07:00.388Z","contentChangedAt":"2026-09-12T12:07:00.388Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}