{"record":{"id":"b8af76271bfb68fa","repo":"symfony/symfony","slug":"unable-to-find-asset-s-referenced-in-s-the","errorCode":null,"errorMessage":"Unable to find asset \"%s\" referenced in \"%s\". The file \"%s\" does not exist.","messagePattern":"Unable to find asset \"(.+?)\" referenced in \"(.+?)\"\\. The file \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"src/Symfony/Component/AssetMapper/Compiler/CssAssetUrlCompiler.php","lineNumber":111,"sourceCode":"\n            $asset->addDependency($dependentAsset);\n            $relativePath = Path::makeRelative($dependentAsset->publicPath, \\dirname($asset->publicPathWithoutDigest));\n\n            return $matches[1][0].'\"'.$relativePath.'\"'.($matches[3][0] ?? '');\n        }, $content, -1, $count, \\PREG_OFFSET_CAPTURE);\n    }\n\n    public function supports(MappedAsset $asset): bool\n    {\n        return 'css' === $asset->publicExtension;\n    }\n\n    private function handleMissingImport(string $message, ?\\Throwable $e = null): void\n    {\n        match ($this->missingImportMode) {\n            AssetCompilerInterface::MISSING_IMPORT_IGNORE => null,\n            AssetCompilerInterface::MISSING_IMPORT_WARN => $this->logger?->warning($message),\n            AssetCompilerInterface::MISSING_IMPORT_STRICT => throw new RuntimeException($message, 0, $e),\n        };\n    }\n}\n","sourceCodeStart":93,"sourceCodeEnd":115,"githubUrl":"https://github.com/symfony/symfony/blob/698e28026c22cf35d032cdb6e800db48b1535790/src/Symfony/Component/AssetMapper/Compiler/CssAssetUrlCompiler.php#L93-L115","documentation":"CssAssetUrlCompiler rewrites url() and @import references in CSS to point at digested public paths of other mapped assets. When Path::join resolves the reference but getAssetFromSourcePath() returns null and the target file is not on disk, it emits this message via handleMissingImport(). Behavior depends on missing_import_mode: 'warn' (default) logs and leaves the URL unchanged, 'strict' throws RuntimeException, 'ignore' is silent.","triggerScenarios":"Compiling a .css asset whose url()/@import match resolves to a source path; getAssetFromSourcePath($resolvedSourcePath) is null and is_file($resolvedSourcePath) is false (the 'does not exist' branch). The message is then routed through handleMissingImport().","commonSituations":"Referenced image/font/CSS was deleted; wrong relative path; typo; file gitignored so absent after clone/deploy; case-sensitivity mismatch between macOS dev and Linux prod; recent rename not propagated to CSS.","solutions":["Confirm the referenced file exists at the resolved path with exact case (check on a case-sensitive filesystem).","If the file exists but is outside a mapped directory, add its directory to asset_mapper.paths.","Correct the relative path in the CSS url()/@import.","Temporarily set missing_import_mode to 'strict' in dev to surface every missing reference as an error."],"exampleFix":"/* before: wrong folder name */\nbackground: url(../img/bg.png);\n\n/* after: correct relative path */\nbackground: url(../images/bg.png);","handlingStrategy":"validation","validationCode":"// Pre-scan a CSS file's url()/@import targets and verify each resolves under a mapped path.\nuse Symfony\\Component\\Filesystem\\Path;\npreg_match_all(CssAssetUrlCompiler::ASSET_URL_PATTERN, $css, $m, PREG_OFFSET_CAPTURE);\nforeach ($m[2] as $ref) {\n    $target = Path::join(dirname($cssSourcePath), $ref[0]);\n    if (!is_file($target)) {\n        throw new \\RuntimeException(\"Missing CSS reference: $ref[0] (resolved to $target)\");\n    }\n}","typeGuard":null,"tryCatchPattern":"// In strict mode, collect all missing references without aborting the whole build.\n$missing = [];\ntry {\n    $compiler->compile($content, $asset, $mapper);\n} catch (\\Symfony\\Component\\AssetMapper\\Exception\\RuntimeException $e) {\n    $missing[] = $e->getMessage();\n    // continue with next file, report $missing at the end\n}","preventionTips":["Keep all referenced assets under directories listed in asset_mapper.paths.","Use case-sensitive filenames consistently (test on Linux before deploy).","Set missing_import_mode to strict in CI to fail on any missing reference."],"tags":["asset-mapper","css","missing-asset","configuration"],"analyzedSha":"698e28026c22cf35d032cdb6e800db48b1535790","analyzedAt":"2026-08-06T23:40:49.025Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}