{"record":{"id":"4e476b46f0fa67aa","repo":"symfony/http-kernel","slug":"collector-s-does-not-exist","errorCode":null,"errorMessage":"Collector \"%s\" does not exist.","messagePattern":"Collector \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"Profiler/Profile.php","lineNumber":231,"sourceCode":"    {\n        foreach ($this->children as $child) {\n            if ($token === $child->getToken()) {\n                return $child;\n            }\n        }\n\n        return null;\n    }\n\n    /**\n     * Gets a Collector by name.\n     *\n     * @throws \\InvalidArgumentException if the collector does not exist\n     */\n    public function getCollector(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    /**\n     * Gets the Collectors associated with this profile.\n     *\n     * @return DataCollectorInterface[]\n     */\n    public function getCollectors(): array\n    {\n        return $this->collectors;\n    }\n\n    /**\n     * Sets the Collectors associated with this profile.\n     *","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/Profiler/Profile.php#L213-L249","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n$queryCount = count($profile->getCollector('db')->getQueries());\n// after\n$queryCount = $profile->hasCollector('db')\n    ? count($profile->getCollector('db')->getQueries())\n    : 0;","handlingStrategy":"type-guard","validationCode":"if ($profile->hasCollector('db')) {\n    $db = $profile->getCollector('db');\n}","typeGuard":"function collector(Profile $profile, string $name): ?DataCollectorInterface {\n    return $profile->hasCollector($name) ? $profile->getCollector($name) : null;\n}","tryCatchPattern":"try {\n    $collector = $profile->getCollector($name);\n} catch (\\InvalidArgumentException $e) {\n    $collector = null; // collector absent on this profile\n}","preventionTips":["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."],"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"}