symfony/http-kernel · error · InvalidArgumentException
Collector " " does not exist.
Error message
Collector "%s" does not exist.
What it means
Profile::getCollector() returns a registered data collector by name and throws InvalidArgumentException when no collector with that name exists on the profile. A profile only holds the collectors that actually ran during request profiling, so asking for a disabled or never-registered collector raises this error.
Solutions
- Check availability first with $profile->hasCollector($name) before calling getCollector().
- Inspect $profile->getCollectors() to see which collectors actually exist on this profile.
- Enable the missing collector in profiler configuration (framework.profiler.collectors or the bundle's own flag) and regenerate the profile.
- Fix the collector name typo — names match the collector service key (e.g. 'request', 'router', 'db').
- Guard code that processes stored profiles so an absent collector is non-fatal.
Example fix
// before
$queryCount = count($profile->getCollector('db')->getQueries());
// after
$queryCount = $profile->hasCollector('db')
? count($profile->getCollector('db')->getQueries())
: 0; Defensive patterns
Strategy: type-guard
Validate before calling
if ($profile->hasCollector('db')) {
$db = $profile->getCollector('db');
} Type guard
function collector(Profile $profile, string $name): ?DataCollectorInterface {
return $profile->hasCollector($name) ? $profile->getCollector($name) : null;
} Try / catch
try {
$collector = $profile->getCollector($name);
} catch (\InvalidArgumentException $e) {
$collector = null; // collector absent on this profile
} Prevention
- Always call hasCollector() before getCollector(), especially on profiles loaded from storage.
- Write profile-processing code defensively: collector sets vary by environment and version.
- Verify collector names after bundle or framework upgrades.
- Enable required collectors explicitly in profiler config for environments where you inspect profiles.
When it happens
Trigger: Calling $profile->getCollector('db') (or any name) on a Profile that was collected without it — the collector is disabled by config, the profile was loaded from storage created with a different collector set, or the collector name is misspelled.
Common situations: Custom code or templates inspecting profiles where some collectors are conditionally enabled per environment, reading historical profiles after adding/removing collectors, or bundles renaming their collector service keys between versions.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Collector " " does not exist.
- Invalid regular expression in the "$
- Please check your configuration. You are trying to use…
- Unable to create the storage directory
- The profiler token " " is invalid: only letters, digits…
AI-assisted analysis of symfony/http-kernel@aa3a39d728 (2026-09-13).
Data as JSON: /api/errors/4e476b46f0fa67aa.
Report an issue: GitHub.
Appendix: source
Thrown at Profiler/Profile.php:231
{
foreach ($this->children as $child) {
if ($token === $child->getToken()) {
return $child;
}
}
return null;
}
/**
* Gets a Collector by name.
*
* @throws \InvalidArgumentException if the collector does not exist
*/
public function getCollector(string $name): DataCollectorInterface
{
if (!isset($this->collectors[$name])) {
throw new \InvalidArgumentException(\sprintf('Collector "%s" does not exist.', $name));
}
return $this->collectors[$name];
}
/**
* Gets the Collectors associated with this profile.
*
* @return DataCollectorInterface[]
*/
public function getCollectors(): array
{
return $this->collectors;
}
/**
* Sets the Collectors associated with this profile.
*View on GitHub (pinned to aa3a39d728)