{"record":{"id":"2865cb754c70f60a","repo":"reflex-dev/reflex","slug":"stylesheet-file-name-cannot-be-empty-stylesheet","errorCode":null,"errorMessage":"Stylesheet file name cannot be empty: {stylesheet_full_path}","messagePattern":"Stylesheet file name cannot be empty: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"reflex/compiler/compiler.py","lineNumber":306,"sourceCode":"\n    Args:\n        stylesheet_full_path: The stylesheet to validate.\n        assets_app_path: The path to the assets directory.\n\n    Raises:\n        ValueError: If the stylesheet is not supported.\n        FileNotFoundError: If the stylesheet is not found.\n    \"\"\"\n    suffix = stylesheet_full_path.suffix[1:] if stylesheet_full_path.suffix else \"\"\n    if suffix not in constants.Reflex.STYLESHEETS_SUPPORTED:\n        msg = f\"Stylesheet file {stylesheet_full_path} is not supported.\"\n        raise ValueError(msg)\n    if not stylesheet_full_path.absolute().is_relative_to(assets_app_path.absolute()):\n        msg = f\"Cannot include stylesheets from outside the assets directory: {stylesheet_full_path}\"\n        raise FileNotFoundError(msg)\n    if not stylesheet_full_path.name:\n        msg = f\"Stylesheet file name cannot be empty: {stylesheet_full_path}\"\n        raise ValueError(msg)\n    if (\n        len(\n            stylesheet_full_path\n            .absolute()\n            .relative_to(assets_app_path.absolute())\n            .parts\n        )\n        == 1\n        and stylesheet_full_path.stem == PageNames.STYLESHEET_ROOT\n    ):\n        msg = f\"Stylesheet file name cannot be '{PageNames.STYLESHEET_ROOT}': {stylesheet_full_path}\"\n        raise ValueError(msg)\n\n\ndef _compile_root_stylesheet(\n    stylesheets: list[str],\n    reset_style: bool = True,\n    plugins: Sequence[Plugin] | None = None,","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/compiler/compiler.py#L288-L324","documentation":"A defensive check in _validate_stylesheet that rejects stylesheet paths with an empty file name component (e.g. a path ending in / or just an extension). Such paths would produce a broken @import in the generated root stylesheet.","triggerScenarios":"Passing strings like \"/styles/\", \".css\", or \"\" in rx.App(add_styles=[...]) (non-URL entries). Path(name) evaluates falsy when the final component is empty, triggering the ValueError.","commonSituations":"Building the stylesheet list programmatically and accidentally appending an empty string or trailing-slash path; f-string path construction bugs that drop the filename.","solutions":["Fix the generated path string to include a real file name","Sanitize the list before passing: [s for s in styles if s and Path(s).name]","Fix the f-string/Path join that produced the truncated path"],"exampleFix":"# before\nstyles = [str(styles_dir / \"\")]  # add_styles=[\"/styles/\"]\n# after\nstyles = [str(styles_dir / \"theme.css\")]","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\nadd_styles = [s for s in style_list if not s.startswith((\"http://\", \"https://\")) or True]\nadd_styles = [s for s in add_styles if Path(s).name and Path(s).stem]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never append empty strings or trailing-slash paths when building style lists programmatically","Unit-test your config-building helpers for empty components","Log the final add_styles list at app construction"],"tags":["reflex","stylesheets","path-validation","empty-path"],"backgroundTag":"empty-path-validation","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}