DioxusLabs/dioxus · error
expected URL to be UTF-8 encoded
Error message
expected URL to be UTF-8 encoded
What it means
The native asset resolver was given a request URL whose bytes are not valid UTF-8, so it cannot be converted to a &str for filesystem or asset-manager lookup. This indicates a malformed or binary-garbage request path.
Solutions
- Ensure the asset URL/path is valid UTF-8; rename the asset or fix the path if it contains non-UTF-8 bytes.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/asset-resolver/src/native.rs:46 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23).
Data as JSON: /api/errors/5746f70cacce2fcd.
Report an issue: GitHub.
Appendix: source
Thrown at packages/asset-resolver/src/native.rs:46
// If the asset exists in the Android asset manager, return the can't be represented as a path
// error instead
if to_java_load_asset(path).is_some() {
return AssetPathError::CannotRepresentAsPath;
}
}
AssetPathError::NotFound
})
}
/// Try to resolve the path of an asset from a given URI path.
fn resolve_asset_path_from_filesystem(path: &str) -> Option<PathBuf> {
// If the user provided a custom asset handler, then call it and return the response if the request was handled.
// The path is the first part of the URI, so we need to trim the leading slash.
let mut uri_path = PathBuf::from(
percent_encoding::percent_decode_str(path)
.decode_utf8()
.expect("expected URL to be UTF-8 encoded")
.as_ref(),
);
// If the asset doesn't exist, or starts with `/assets/`, then we'll try to serve out of the bundle
// This lets us handle both absolute and relative paths without being too "special"
// It just means that our macos bundle is a little "special" because we need to place an `assets`
// dir in the `Resources` dir.
//
// If there's no asset root, we use the cargo manifest dir as the root, or the current dir
if !uri_path.exists() || uri_path.starts_with("/assets/") {
let bundle_root = get_asset_root();
let relative_path = uri_path.strip_prefix("/").unwrap();
uri_path = bundle_root.join(relative_path);
}
// If the asset exists, return it
uri_path.exists().then_some(uri_path)
}View on GitHub (pinned to 24f6a829df)