cakephp/cakephp · warning · LogicException
No crumb matching ` ` could be found.
Error message
No crumb matching `%s` could be found.
What it means
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.
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.
Example fix
// before
$breadcrumbs->insertBefore('Dashbaord', 'Reports', ['action' => 'reports']); // typo
// after
$breadcrumbs->insertBefore('Dashboard', 'Reports', ['action' => 'reports']); Defensive patterns
Strategy: try-catch
Validate before calling
if ($breadcrumbs->findCrumb($matchingTitle) === null) {
$breadcrumbs->add($matchingTitle, '/');
} Try / catch
try {
$breadcrumbs->insertBefore($anchor, $title, $url);
} catch (\LogicException $e) {
$breadcrumbs->add($title, $url);
} Prevention
- 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.
When it happens
Trigger: $breadcrumbs->insertBefore('Dashboard', 'Sub', '/') when no crumb titled 'Dashboard' was added — titles are compared exactly, so case or whitespace differences also fail.
Common situations: 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.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- No crumb could be found at index
- A named route was found for
- A required argument cannot follow an optional one
- A rule with the name
- A validation rule with the name
AI-assisted analysis of cakephp/cakephp@1128eba9b0 (2026-09-12).
Data as JSON: /api/errors/e6cfad68f54bc0da.
Report an issue: GitHub.
Appendix: source
Thrown at src/View/Helper/BreadcrumbsHelper.php:250
* @param array<string, mixed> $options Array of options. These options will be used as HTML attributes the crumb will
* be rendered in (a <li> tag by default). It accepts two special keys:
*
* - *innerAttrs*: An array that allows you to define attributes for the inner element of the crumb (by default, to
* the link)
* - *templateVars*: Specific template vars in case you override the templates provided.
* @return $this
* @throws \LogicException In case the matching crumb can not be found
*/
public function insertBefore(
string $matchingTitle,
string $title,
array|string|null $url = null,
array $options = [],
) {
$key = $this->findCrumb($matchingTitle);
if ($key === null) {
throw new LogicException(sprintf('No crumb matching `%s` could be found.', $matchingTitle));
}
return $this->insertAt($key, $title, $url, $options);
}
/**
* Insert a crumb after the first matching crumb with the specified title.
*
* Finds the index of the first crumb that matches the provided class,
* and inserts the supplied callable before it.
*
* @param string $matchingTitle The title of the crumb you want to insert this one after.
* @param string $title Title of the crumb.
* @param array|string|null $url URL of the crumb. Either a string, an array of route params to pass to
* Url::build() or null / empty if the crumb does not have a link.
* @param array<string, mixed> $options Array of options. These options will be used as HTML attributes the crumb will
* be rendered in (a <li> tag by default). It accepts two special keys:
*View on GitHub (pinned to 1128eba9b0)