sxyazi/yazi · error
URL path kind does not match Auth kind
Error message
URL path kind does not match Auth kind
What it means
validate_auth_path pairs an AuthArc with a PathDyn and checks they agree: the auth's path kind (derived from its scheme) must equal the path's kind. A mismatch (e.g. Unix auth with an OS/Windows path) means the URL was assembled from incompatible parts, so validation fails. It also checks hub parent depth consistency after this check.
Source
Thrown at yazi-shared/src/url/cow.rs:207
where
S: serde::Serializer,
{
self.as_url().serialize(serializer)
}
}
impl<'de> Deserialize<'de> for UrlCow<'_> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
UrlBuf::deserialize(deserializer).map(UrlCow::from)
}
}
fn validate_auth_path(auth: &AuthArc, path: PathDyn) -> Result<()> {
auth.validate()?;
ensure!(auth.path_kind()? == path.kind(), "URL path kind does not match Auth kind");
if auth.kind.is_hub() {
ensure!(
auth.parent_depth() == path.components().auth_depth(),
"Hub URL parent depth does not match its path"
);
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
use crate::url::UrlLike;
#[test]
fn test_parse() -> Result<()> {
crate::init_tests();View on GitHub (pinned to 8ebf930f17)
Solutions
- Make the path kind match the auth kind — use a Unix path for Unix/Sftp auths and an OS path for local auths.
- Reconstruct the URL from its canonical parts (scheme, auth, loc) using the Url/UrlBuf constructors instead of splicing raw paths.
- Regenerate serialized state with the same platform/version that will consume it.
Example fix
// before
let cow = UrlCow::try_from((unix_auth, PathDyn::os("C:\\data")))?;
// after
let cow = UrlCow::try_from((unix_auth, PathDyn::unix("/data")))?; Defensive patterns
Strategy: validation
Validate before calling
// before constructing UrlCow
if auth.path_kind()? != path.kind() {
return Err(anyhow!("auth/path kind mismatch"));
} Type guard
fn kinds_match(auth: &AuthArc, path: PathDyn) -> bool { auth.path_kind().map(|k| k == path.kind()).unwrap_or(false) } Try / catch
// on deserialization
let cow = UrlCow::try_from(raw).context("invalid serialized URL: auth/path mismatch")?; Prevention
- Construct URLs from canonical parts rather than splicing raw path strings.
- Don't move serialized URL state across platforms without regenerating it.
- Check path kind against scheme whenever assembling auth + path manually.
When it happens
Trigger: Calling `UrlCow::try_from(...)` or `with_ports` with an auth and path whose kinds disagree — e.g. deserializing a URL whose auth is Sftp/Unix but whose path component is a Windows-style OS path, or vice versa.
Common situations: Hand-editing or migrating serialized URL/auth state across platforms; constructing UrlCow manually from mixed sources (Unix loc + OS path); restoring a cache written on a different OS.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- View auth requires view metadata
- Non-view auth cannot have view metadata
- View source must be Regular or Sftp
- View authority required
- Paths must be both absolute or both relative: {from:?} and {
AI-assisted analysis of sxyazi/yazi@8ebf930f17 (2026-09-09).
Data as JSON: /api/errors/a6429db8e518180f.
Report an issue: GitHub.