{"record":{"id":"5746f70cacce2fcd","repo":"DioxusLabs/dioxus","slug":"expected-url-to-be-utf-8-encoded","errorCode":null,"errorMessage":"expected URL to be UTF-8 encoded","messagePattern":"expected URL to be UTF-8 encoded","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/asset-resolver/src/native.rs","lineNumber":46,"sourceCode":"            // If the asset exists in the Android asset manager, return the can't be represented as a path\n            // error instead\n            if to_java_load_asset(path).is_some() {\n                return AssetPathError::CannotRepresentAsPath;\n            }\n        }\n\n        AssetPathError::NotFound\n    })\n}\n\n/// Try to resolve the path of an asset from a given URI path.\nfn resolve_asset_path_from_filesystem(path: &str) -> Option<PathBuf> {\n    // If the user provided a custom asset handler, then call it and return the response if the request was handled.\n    // The path is the first part of the URI, so we need to trim the leading slash.\n    let mut uri_path = PathBuf::from(\n        percent_encoding::percent_decode_str(path)\n            .decode_utf8()\n            .expect(\"expected URL to be UTF-8 encoded\")\n            .as_ref(),\n    );\n\n    // If the asset doesn't exist, or starts with `/assets/`, then we'll try to serve out of the bundle\n    // This lets us handle both absolute and relative paths without being too \"special\"\n    // It just means that our macos bundle is a little \"special\" because we need to place an `assets`\n    // dir in the `Resources` dir.\n    //\n    // If there's no asset root, we use the cargo manifest dir as the root, or the current dir\n    if !uri_path.exists() || uri_path.starts_with(\"/assets/\") {\n        let bundle_root = get_asset_root();\n        let relative_path = uri_path.strip_prefix(\"/\").unwrap();\n        uri_path = bundle_root.join(relative_path);\n    }\n\n    // If the asset exists, return it\n    uri_path.exists().then_some(uri_path)\n}","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/asset-resolver/src/native.rs#L28-L64","documentation":"Runtime panic inside the desktop asset resolver's custom protocol handler. The request's URI path is percent-decoded and required to be valid UTF-8; `decode_utf8().expect(...)` in resolve_asset_path_from_filesystem panics when the decoded bytes are not UTF-8.","triggerScenarios":"Any asset request whose percent-encoded path decodes to invalid UTF-8 (e.g. a reference containing %FF%FE) hitting the desktop custom protocol when the webview loads an asset.","commonSituations":"Broken href/src values produced by string concatenation; browser prefetch or extension probes with malformed URLs; asset filenames copied from non-UTF-8 filesystems into references.","solutions":["Fix the asset reference generating the malformed percent-encoded URL","Ensure referenced asset filenames are valid UTF-8","Upgrade dioxus-desktop if a newer version returns an error response instead of panicking on undecodable paths"],"exampleFix":"// before (malformed reference in rsx)\nrsx! { img { src: \"assets/icon%FF.png\" } }\n\n// after\nrsx! { img { src: asset!(\"/assets/icon.png\") } }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate asset URLs with proper percent-encoding instead of raw string concatenation","Keep asset filenames valid UTF-8 and free of characters needing exotic encoding","Use the asset!() macro for references so paths stay canonical"],"tags":["desktop","assets","url-encoding","utf8","panic","runtime"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}