sxyazi/yazi · error
Non-view auth cannot have view metadata
Error message
Non-view auth cannot have view metadata
What it means
The mirror case of the view-auth check: a non-view auth (Regular, Sftp, Hub) must not carry view metadata. If `self.kind.is_view()` is false but `self.view.auth()` returns Some, validate() rejects it as contradictory. View metadata is only meaningful on view-kind authorities.
Source
Thrown at yazi-shared/src/auth/auth.rs:61
#[inline]
pub fn physical(&self) -> &Self { self.view.auth().map_or(self, |a| a) }
#[inline]
pub(crate) fn path_kind(&self) -> Result<PathKind> { self.physical().kind.try_into() }
#[inline]
pub fn covariant(&self, other: &Self) -> bool { self.physical() == other.physical() }
pub fn same_service(&self, other: &Self) -> bool {
self.covariant(other)
|| self.kind.is_hub() && other.kind.is_hub() && self.scheme == other.scheme
}
pub(crate) fn validate(&self) -> Result<()> {
match (self.kind.is_view(), self.view.auth()) {
(true, None) => bail!("View auth requires view metadata"),
(false, Some(_)) => bail!("Non-view auth cannot have view metadata"),
(true, Some(source)) => {
ensure!(source.is_regular() || source.kind.is_sftp(), "View source must be Regular or Sftp")
}
_ => {}
}
Ok(())
}
pub(crate) fn parent_depth(&self) -> usize {
let mut depth = 0;
let mut parent = self.parent.as_ref();
while let Some(auth) = parent {
depth += 1;
parent = auth.parent.as_ref();
}
depth
}
}View on GitHub (pinned to 8ebf930f17)
Solutions
- Clear the view metadata (set `view` to None / omit it) for non-view kinds before validating.
- If the auth really is a view, set its kind to the intended view variant instead.
- Rebuild the auth from scratch with the correct kind and metadata rather than mutating kind in place.
Example fix
// before let auth = regular_auth.with_view(stale_view); auth.validate()?; // after let auth = regular_auth; // no view metadata on non-view kinds auth.validate()?;
Defensive patterns
Strategy: validation
Validate before calling
fn auth_is_consistent(auth: &Auth) -> bool { auth.kind.is_view() == auth.view.auth().is_some() } Type guard
fn view_meta(auth: &Auth) -> Option<&View> { auth.kind.is_view().then(|| auth.view.auth()).flatten() } Prevention
- When changing an auth's kind, clear or rebuild its view metadata in the same step.
- Avoid field-by-field cloning of auth structs; use constructors.
- Treat kind and view metadata as a single invariant unit.
When it happens
Trigger: Calling `Auth::validate()` on an auth whose kind is not a view but whose `view` field is set to Some, e.g. by reusing a previously-view auth builder or converting a view auth to another kind without clearing the view field.
Common situations: Mutating auth kind (e.g. demoting a view to regular) without dropping the view payload; copying auth structs field-by-field and keeping stale view data; cache entries written by a buggy intermediate version.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- View auth requires view metadata
- URL path kind does not match Auth kind
- View source must be Regular or Sftp
- View authority required
- not a URL
AI-assisted analysis of sxyazi/yazi@8ebf930f17 (2026-09-09).
Data as JSON: /api/errors/dbc79f0898dc4d58.
Report an issue: GitHub.