{"record":{"id":"5308ee85d3a2201a","repo":"phalcon/cphalcon","slug":"path-path-is-not-a-valid-target-path-it-is-a","errorCode":null,"errorMessage":"Path '{path}' is not a valid target path, it is a directory.","messagePattern":"Path '(.+?)' is not a valid target path, it is a directory\\.","errorType":"exception","errorClass":"Phalcon\\Assets\\Exceptions\\TargetPathIsDirectory","httpStatus":null,"severity":"error","filePath":"phalcon/Assets/Manager.zep","lineNumber":471,"sourceCode":"\n            /**\n             * Check if the collection have its own target base path\n             */\n            let join = collection->getJoin();\n\n            /**\n             * Check for valid target paths if the collection must be joined\n             */\n            if !join {\n                /**\n                 * We need a valid final target path\n                 */\n                if (true === empty(completeTargetPath)) {\n                    throw new InvalidTargetPath(completeTargetPath);\n                }\n\n                if (true === is_dir(completeTargetPath)) {\n                    throw new TargetPathIsDirectory(completeTargetPath);\n                }\n            }\n        }\n\n        /** @var Asset $asset */\n        for asset in assets {\n            let filterNeeded = false;\n\n            /**\n             * If the collection must not be joined we must print a HTML for\n             * each one\n             */\n            if (true !== empty(filters)) {\n                let sourcePath = asset->getPath();\n                if (true === asset->isLocal()) {\n                    let filterNeeded = true;\n                    /**\n                     * Get the complete path","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Assets/Manager.zep#L453-L489","documentation":"Before writing filtered asset output the manager validates the resolved final target path. If is_dir() reports the path as an existing directory it throws TargetPathIsDirectory, because file_put_contents cannot write a file over a directory and the filter step would fail anyway.","triggerScenarios":"A filtered collection whose targetPath resolves to an existing directory, e.g. `setTargetPath('css')` or 'css/' where 'css' is a real folder under targetBasePath, then outputCss()/outputJs().","commonSituations":"Passing a directory instead of a file path by analogy with other path options; targetPath that collides with a folder name on case-insensitive filesystems; copying a config where the trailing '/app.min.css' segment was dropped.","solutions":["Point targetPath at a file: `$collection->setTargetPath('css/combined.css')`","Check `is_dir($targetBasePath . $targetPath)` and pick a name that is not an existing directory","If the directory name is intentional, rename the directory or choose a distinct output filename"],"exampleFix":"// before\n$collection->setTargetPath('css'); // 'css' is a directory\n// after\n$collection->setTargetPath('css/combined.css');","handlingStrategy":"validation","validationCode":"$finalTarget = $targetBasePath . $collection->getTargetPath();\nif (is_dir($finalTarget)) {\n    throw new RuntimeException('Asset target path is an existing directory: ' . $finalTarget);\n}\necho $assets->outputCss($name);","typeGuard":null,"tryCatchPattern":"try {\n    echo $assets->outputCss('header');\n} catch (\\Phalcon\\Assets\\Exceptions\\TargetPathIsDirectory $e) {\n    $logger->error('Fix asset target path (points at a directory): ' . $e->getMessage());\n    throw $e;\n}","preventionTips":["Always set targetPath as a file path including the filename ('css/app.css'), not a folder","Validate target paths in a build/deploy lint step with is_dir()","Watch for name collisions between output files and existing directories on case-insensitive filesystems"],"tags":["assets","target-path","filesystem","validation"],"backgroundTag":"path-is-a-directory","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}