{"record":{"id":"a5133060dd8a8bc6","repo":"DioxusLabs/dioxus","slug":"failed-to-read-name-of-css-module-file","errorCode":null,"errorMessage":"Failed to read name of css module file `{}`.","messagePattern":"Failed to read name of css module file `(.+?)`\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/opt/css.rs","lineNumber":58,"sourceCode":"        )\n    })?;\n\n    Ok(())\n}\n\npub(crate) fn process_css_module(\n    css_options: &CssModuleAssetOptions,\n    source: &Path,\n    output_path: &Path,\n) -> anyhow::Result<()> {\n    let css = std::fs::read_to_string(source)?;\n\n    // Collect the file hash name.\n    let mut src_name = source\n        .file_name()\n        .and_then(|x| x.to_str())\n        .ok_or_else(|| {\n            anyhow!(\n                \"Failed to read name of css module file `{}`.\",\n                source.display()\n            )\n        })?\n        .strip_suffix(\".css\")\n        .ok_or_else(|| {\n            anyhow!(\n                \"Css module file `{}` should end with a `.css` suffix.\",\n                source.display(),\n            )\n        })?\n        .to_string();\n\n    src_name.push('-');\n\n    let hash = create_module_hash(source);\n    let css = transform_css(css.as_str(), hash.as_str()).map_err(|error| {\n        anyhow!(","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/cli/src/opt/css.rs#L40-L76","documentation":"process_css_module derives a hashed output name from the CSS module's file name, first converting the OsStr file name to &str. If the name is not valid UTF-8, to_str() returns None and dx errors with the offending path before any CSS processing happens.","triggerScenarios":"A *.module.css asset whose file name contains non-UTF-8 bytes (e.g. written by a tool using a legacy 8-bit encoding) being processed by the dx asset pipeline.","commonSituations":"Files copied from old Windows shares or zip archives with mis-decoded names; unusual byte sequences in asset names on Linux/macOS.","solutions":["Rename the file to a valid UTF-8 name (plain ASCII is safest)","Audit asset directories for undecodable names (ls | iconv -f utf-8 -t utf-8 surfaces them as errors)","Keep asset generation tooling configured to emit UTF-8/ASCII file names"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Guard asset collection before the build\nfn assert_utf8_css_module_names(files: &[std::path::PathBuf]) {\n    for f in files {\n        assert!(f.file_name().and_then(|n| n.to_str()).is_some(), \"non-UTF-8 file name: {f:?}\");\n    }\n}","typeGuard":"fn is_utf8_path(p: &std::path::Path) -> bool { p.to_str().is_some() }","tryCatchPattern":null,"preventionTips":["Keep asset file names ASCII","Normalize names when copying assets from legacy-encoding sources","Add a pre-build check over your assets directory for undecodable names"],"tags":["cli","css-modules","assets","utf-8","filesystem"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}