symfony/http-kernel · error · InvalidArgumentException
Collector " " does not exist.
Error message
Collector "%s" does not exist.
What it means
Profiler::get() exposes the profiler's registered collectors by name and throws InvalidArgumentException if no collector with that name is registered. It is a thin array lookup over the collectors set up at profiler construction, so any unregistered name triggers the error.
Solutions
- Check existence first with $profiler->has($name) before calling get().
- Verify the collector service is registered and tagged 'data_collector' (or listed in framework.profiler config) for the current environment.
- Fix the collector name typo — the key equals the name used at registration.
- In tests, enable the collector in the test kernel configuration or assert with has().
- If the collector was removed in an upgrade, migrate calling code to the new collector name or API.
Example fix
// before
$collector = $profiler->get('twig');
// after
if ($profiler->has('twig')) {
$collector = $profiler->get('twig');
} else {
$collector = null; // collector not enabled in this environment
} Defensive patterns
Strategy: type-guard
Validate before calling
if ($profiler->has('db')) {
$dbCollector = $profiler->get('db');
} Type guard
function getCollectorSafe(Profiler $profiler, string $name): ?DataCollectorInterface {
return $profiler->has($name) ? $profiler->get($name) : null;
} Try / catch
try {
$collector = $profiler->get($name);
} catch (\InvalidArgumentException $e) {
$collector = null; // not registered in this environment
} Prevention
- Call has() before get() whenever collector availability is environment-dependent.
- Register all needed collectors explicitly via 'data_collector' tags or profiler config.
- Keep collector names in constants/config rather than scattered string literals.
- Re-check collector service ids after upgrading Symfony or third-party profiler bundles.
When it happens
Trigger: Calling $profiler->get('db') when the collector was never registered — collector disabled via config in the current environment, service removed in a bundle upgrade, collector only enabled in dev but accessed in prod, or a misspelled collector name.
Common situations: Code reading collectors directly (custom listeners, functional-test assertions) running where the collector is disabled; refactoring after a bundle renamed its collector service id; calling get() before any add() ran on a manually built Profiler.
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/2b89c4e453a70f07.
Report an issue: GitHub.
Appendix: source
Thrown at Profiler/Profiler.php:245
*
* @param string $name A collector name
*/
public function has(string $name): bool
{
return isset($this->collectors[$name]);
}
/**
* Gets a Collector by name.
*
* @param string $name A collector name
*
* @throws \InvalidArgumentException if the collector does not exist
*/
public function get(string $name): DataCollectorInterface
{
if (!isset($this->collectors[$name])) {
throw new \InvalidArgumentException(\sprintf('Collector "%s" does not exist.', $name));
}
return $this->collectors[$name];
}
private function getTimestamp(?string $value): ?int
{
if (null === $value || '' === $value) {
return null;
}
try {
$value = new \DateTimeImmutable(is_numeric($value) ? '@'.$value : $value);
} catch (\Exception) {
return null;
}
return $value->getTimestamp();View on GitHub (pinned to aa3a39d728)