{"record":{"id":"21ab8a53e1102238","repo":"symfony/http-kernel","slug":"s-warmup-should-return-a-list-of-files-or-classes-but-s-is","errorCode":null,"errorMessage":"\"%s::warmUp()\" should return a list of files or classes but \"%s\" is none of them.","messagePattern":"\"(.+?)::warmUp\\(\\)\" should return a list of files or classes but \"(.+?)\" is none of them\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"CacheWarmer/CacheWarmerAggregate.php","lineNumber":98,"sourceCode":"\n                return null;\n            });\n        }\n\n        $preload = [];\n        try {\n            foreach ($this->warmers as $warmer) {\n                if (!$this->optionalsEnabled && $warmer->isOptional()) {\n                    continue;\n                }\n                if ($this->onlyOptionalsEnabled && !$warmer->isOptional()) {\n                    continue;\n                }\n\n                $start = microtime(true);\n                foreach ($warmer->warmUp($cacheDir, $buildDir) as $item) {\n                    if (is_dir($item) || (str_starts_with($item, \\dirname($cacheDir)) && !is_file($item)) || ($buildDir && str_starts_with($item, \\dirname($buildDir)) && !is_file($item))) {\n                        throw new \\LogicException(\\sprintf('\"%s::warmUp()\" should return a list of files or classes but \"%s\" is none of them.', $warmer::class, $item));\n                    }\n                    $preload[] = $item;\n                }\n\n                if ($io?->isDebug()) {\n                    $io->info(\\sprintf('\"%s\" completed in %0.2fms.', $warmer::class, 1000 * (microtime(true) - $start)));\n                }\n            }\n        } finally {\n            if ($collectDeprecations) {\n                restore_error_handler();\n\n                if ($h = fopen($this->deprecationLogsFilepath, 'c+')) {\n                    flock($h, \\LOCK_EX);\n\n                    set_error_handler(static fn () => true);\n                    try {\n                        $previousLogs = unserialize(stream_get_contents($h), ['allowed_classes' => false]);","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/symfony/http-kernel/blob/aa3a39d7286a62cdfea98f0e69c651a3da6e36cf/CacheWarmer/CacheWarmerAggregate.php#L80-L116","documentation":"CacheWarmerAggregate::warmUp() iterates each warmer's warmUp() return values and requires them to be existing files/directories under the cache dir or class names for preload. A LogicException is thrown when a warmer returns an item that is neither (e.g. a non-existent path or invalid string), catching warmer implementations that violate the contract.","triggerScenarios":"A custom CacheWarmerInterface::warmUp() returns an array containing a path that is not an existing file under dirname($cacheDir)/dirname($buildDir), or a malformed entry that is neither a valid path nor a class name.","commonSituations":"Custom warmers returning generated file paths that were never written, returning relative paths outside the cache dir, or (after Symfony 6.3 contract change) returning wrong/empty string items; upgrading Symfony where warmer return values became meaningful for preload.","solutions":["Fix the warmer so warmUp() returns only existing absolute file paths under the cache/build dir or valid class names.","If the warmer writes no files, return [] (or only class names to preload).","Verify paths exist after writing them in the warmer (file_exists assertion) before returning them."],"exampleFix":"// before\nclass MyWarmer implements CacheWarmerInterface\n{\n    public function warmUp(string $cacheDir, ?string $buildDir = null): array\n    {\n        return ['var/cache/prod/missing.xml']; // never written\n    }\n}\n// after\nclass MyWarmer implements CacheWarmerInterface\n{\n    public function warmUp(string $cacheDir, ?string $buildDir = null): array\n    {\n        $file = $cacheDir.'/my/data.php';\n        file_put_contents($file, '<?php return [];');\n        return [$file];\n    }\n}","handlingStrategy":"validation","validationCode":"$items = $warmer->warmUp($cacheDir, $buildDir);\nforeach ($items as $item) {\n    $valid = is_dir($item) || is_file($item) || (class_exists($item) && interface_exists($item) === false);\n    if (!$valid) { throw new \\AssertionError(\"Invalid warmer return: $item\"); }\n}","typeGuard":null,"tryCatchPattern":"try { $aggregate->warmUp($cacheDir); } catch (\\LogicException $e) { /* fix the offending warmer named in the message */ }","preventionTips":["Unit-test custom warmers to assert return values exist on disk or are class names","Return [] when a warmer produces no preloadable artifacts","Keep warmer paths absolute and inside the cache/build dir"],"tags":["symfony","cache-warmup","contract-violation"],"backgroundTag":"internal-invariant-violation","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"}