sxyazi/yazi · error
View auth requires view metadata
Error message
View auth requires view metadata
What it means
Auth::validate() enforces that any auth record whose kind is a view carries view metadata (an inner View with a source auth and wire data). If an auth is marked as a view kind but `view.auth()` returns None, the record is structurally invalid and validation bails. This prevents half-constructed view authorities from entering the URL system.
Source
Thrown at yazi-shared/src/auth/auth.rs:60
pub fn is_remote(&self) -> bool { self.kind.is_sftp() || self.view.is_remote() }
#[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
- Populate the view metadata (View { source, data }) on the auth before validating, e.g. via `UrlBuf::into_view(auth, data)` which builds it from the physical URL auth.
- Check the auth kind: if you do not intend a view, use a non-view kind (Regular/Sftp/Hub) instead of a view kind.
- If data came from a serialized cache/config, regenerate it with the current yazi version so view metadata is present.
Example fix
// before
let auth = AuthArc::new(Auth { kind: AuthKind::view_default(), view: None });
// after
let source = url.physical().auth().clone();
let auth = auth.with_view(View { source, data });
auth.validate()?; Defensive patterns
Strategy: validation
Validate before calling
fn is_view_auth(auth: &Auth) -> bool { auth.kind.is_view() && auth.view.auth().is_some() }
// call is_view_auth(&auth) before validate()/use Type guard
fn as_view(auth: &Auth) -> Option<&View> { auth.kind.is_view().then(|| auth.view.auth()).flatten() } Prevention
- Always build view auth via constructors like with_view/into_view instead of struct literals.
- Never set a view kind without also setting View { source, data }.
- When deserializing old state, re-validate and regenerate entries missing view metadata.
When it happens
Trigger: Constructing an AuthArc/Auth with kind set to a view variant while leaving the `view` field absent/None, then calling `Auth::validate()` (directly or via `UrlBuf::into_view` / `validate_auth_path`).
Common situations: Hand-building view auth entries in custom fetch/preload providers; deserializing auth data from an older config or cache format that lacked view metadata; writing a plugin that clones kind info but not the view payload.
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
- Non-view auth cannot have 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/013fa5960bce9f6e.
Report an issue: GitHub.