{"record":{"id":"2b89c4e453a70f07","repo":"symfony/http-kernel","slug":"collector-s-does-not-exist-profiler","errorCode":null,"errorMessage":"Collector \"%s\" does not exist.","messagePattern":"Collector \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Profiler/Profiler.php","lineNumber":245,"sourceCode":"     *\n     * @param string $name A collector name\n     */\n    public function has(string $name): bool\n    {\n        return isset($this->collectors[$name]);\n    }\n\n    /**\n     * Gets a Collector by name.\n     *\n     * @param string $name A collector name\n     *\n     * @throws \\InvalidArgumentException if the collector does not exist\n     */\n    public function get(string $name): DataCollectorInterface\n    {\n        if (!isset($this->collectors[$name])) {\n            throw new \\InvalidArgumentException(\\sprintf('Collector \"%s\" does not exist.', $name));\n        }\n\n        return $this->collectors[$name];\n    }\n\n    private function getTimestamp(?string $value): ?int\n    {\n        if (null === $value || '' === $value) {\n            return null;\n        }\n\n        try {\n            $value = new \\DateTimeImmutable(is_numeric($value) ? '@'.$value : $value);\n        } catch (\\Exception) {\n            return null;\n        }\n\n        return $value->getTimestamp();","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/Profiler/Profiler.php#L227-L263","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n$collector = $profiler->get('twig');\n// after\nif ($profiler->has('twig')) {\n    $collector = $profiler->get('twig');\n} else {\n    $collector = null; // collector not enabled in this environment\n}","handlingStrategy":"type-guard","validationCode":"if ($profiler->has('db')) {\n    $dbCollector = $profiler->get('db');\n}","typeGuard":"function getCollectorSafe(Profiler $profiler, string $name): ?DataCollectorInterface {\n    return $profiler->has($name) ? $profiler->get($name) : null;\n}","tryCatchPattern":"try {\n    $collector = $profiler->get($name);\n} catch (\\InvalidArgumentException $e) {\n    $collector = null; // not registered in this environment\n}","preventionTips":["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."],"tags":["symfony","profiler","collector","key-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"aa3a39d7286a62cdfea98f0e69c651a3da6e36cf","analyzedAt":"2026-09-13T18:03:36.509Z","contentChangedAt":"2026-09-13T18:03:36.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}