{"record":{"id":"d58472f276c184b6","repo":"phalcon/cphalcon","slug":"asset-path-does-not-have-a-valid-source-path","errorCode":null,"errorMessage":"Asset '{path}' does not have a valid source path","messagePattern":"Asset '(.+?)' does not have a valid source path","errorType":"exception","errorClass":"Phalcon\\Assets\\Exceptions\\InvalidAssetSourcePath","httpStatus":null,"severity":"error","filePath":"phalcon/Assets/Manager.zep","lineNumber":499,"sourceCode":"             * 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\n                     */\n                    let sourcePath = asset->getRealSourcePath(completeSourcePath);\n\n                    /**\n                     * We need a valid source path\n                     */\n                    if (true === empty(sourcePath)) {\n                        let sourcePath = asset->getPath();\n\n                        throw new InvalidAssetSourcePath(sourcePath);\n                    }\n                }\n\n                /**\n                 * Get the target path, we need to write the filtered content to\n                 * a file\n                 */\n                let targetPath = asset->getRealTargetPath(completeTargetPath);\n\n                /**\n                 * We need a valid final target path\n                 */\n                if (true === empty(targetPath)) {\n                    throw new InvalidAssetTargetPath(asset->getPath());\n                }\n\n                if (true === asset->isLocal()) {\n                    /**","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Assets/Manager.zep#L481-L517","documentation":"While processing a filtered local asset the manager computes the real source path (base + asset path); if that comes back empty the manager reports the asset's own path in an InvalidAssetSourcePath exception. Empty here means the asset has no usable source location — typically the file does not exist so getRealSourcePath() yields nothing.","triggerScenarios":"A filtered local asset whose file is missing at sourceBasePath . path when outputCss()/outputJs() runs; an asset constructed with an empty path; wrong 'sourceBasePath' so every lookup misses.","commonSituations":"Building CSS/JS in CI where bower/npm assets have not been fetched yet; wrong docroot base path in a Docker image; asset path starting with '/' that double-joins with the base path.","solutions":["Check the file exists: `var_dump(is_file($sourceBasePath . $asset->getPath()))` and fix the path or base","Correct the Manager's 'sourceBasePath' option or the asset's path so the concatenation points at the real file","Install the missing frontend dependencies before building assets","Mark remote/CDN assets with `$asset->setLocal(false)` so no local read is attempted"],"exampleFix":"// before\n$assets = new \\Phalcon\\Assets\\Manager(['sourceBasePath' => '/app/public']);\n$collection->addJs('/js/app.js', true, false); // resolves to /app/public/js/app.js which is missing\n// after: deploy the file or fix the base\n$assets = new \\Phalcon\\Assets\\Manager(['sourceBasePath' => '/app/public']);\n$collection->addJs('js/app.js', true, false);","handlingStrategy":"validation","validationCode":"$source = rtrim($sourceBasePath, '/') . '/' . ltrim($asset->getPath(), '/');\nif (!is_file($source)) {\n    throw new RuntimeException('Cannot filter asset, source file missing: ' . $source);\n}\necho $assets->outputJs($name);","typeGuard":null,"tryCatchPattern":"try {\n    echo $assets->outputJs('footer');\n} catch (\\Phalcon\\Assets\\Exceptions\\InvalidAssetSourcePath $e) {\n    $logger->error('Asset source missing/unresolvable: ' . $e->getMessage());\n    echo $assets->outputJs(null); // degrade to unfiltered tags if acceptable\n}","preventionTips":["Verify frontend dependencies (npm/bower assets) are installed before the asset build runs in CI","Keep sourceBasePath in one config source and test it with a health check","Use relative asset paths without a leading '/' to avoid double-joining with the base path"],"tags":["assets","source-path","filters","filesystem"],"backgroundTag":"missing-source-file","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}