{"record":{"id":"eba497c4763b613e","repo":"sxyazi/yazi","slug":"view-source-must-be-regular-or-sftp","errorCode":null,"errorMessage":"View source must be Regular or Sftp","messagePattern":"View source must be Regular or Sftp","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-shared/src/auth/auth.rs","lineNumber":63,"sourceCode":"\tpub fn physical(&self) -> &Self { self.view.auth().map_or(self, |a| a) }\n\n\t#[inline]\n\tpub(crate) fn path_kind(&self) -> Result<PathKind> { self.physical().kind.try_into() }\n\n\t#[inline]\n\tpub fn covariant(&self, other: &Self) -> bool { self.physical() == other.physical() }\n\n\tpub fn same_service(&self, other: &Self) -> bool {\n\t\tself.covariant(other)\n\t\t\t|| self.kind.is_hub() && other.kind.is_hub() && self.scheme == other.scheme\n\t}\n\n\tpub(crate) fn validate(&self) -> Result<()> {\n\t\tmatch (self.kind.is_view(), self.view.auth()) {\n\t\t\t(true, None) => bail!(\"View auth requires view metadata\"),\n\t\t\t(false, Some(_)) => bail!(\"Non-view auth cannot have view metadata\"),\n\t\t\t(true, Some(source)) => {\n\t\t\t\tensure!(source.is_regular() || source.kind.is_sftp(), \"View source must be Regular or Sftp\")\n\t\t\t}\n\t\t\t_ => {}\n\t\t}\n\t\tOk(())\n\t}\n\n\tpub(crate) fn parent_depth(&self) -> usize {\n\t\tlet mut depth = 0;\n\t\tlet mut parent = self.parent.as_ref();\n\t\twhile let Some(auth) = parent {\n\t\t\tdepth += 1;\n\t\t\tparent = auth.parent.as_ref();\n\t\t}\n\t\tdepth\n\t}\n}\n\nimpl<'de> Deserialize<'de> for Auth {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/sxyazi/yazi/blob/8ebf930f1796ae2076b7d6b0c5e93a1002c18134/yazi-shared/src/auth/auth.rs#L45-L81","documentation":"For a valid view auth, validate() additionally requires the view's SOURCE auth to be either a Regular (local) or Sftp authority. Views must be backed by an actual browsable filesystem; a view whose source is another view, hub, or other exotic kind is rejected.","triggerScenarios":"Calling `Auth::validate()` on a view-kind auth whose inner `View.source` auth kind is neither regular nor Sftp — e.g. stacking a view on top of a view, or pointing a view at a hub authority.","commonSituations":"Building nested views (view-of-view) in plugins; deriving view auth from a hub URL; programmatic auth construction where the source was taken from the wrong URL layer.","solutions":["Point the view's source at a Regular (local path) or Sftp auth — take it from `url.physical().auth()` of a concrete local/SFTP location.","Remove the intermediate view/hub layer so the view wraps a concrete filesystem auth.","If you need derived views, add an explicit yazi-level mechanism instead of nesting view authorities."],"exampleFix":"// before\nlet source = other_view_auth.clone(); // a view auth\n// after\nlet source = url.physical().auth().clone(); // Regular or Sftp auth\nlet auth = auth.with_view(View { source, data });","handlingStrategy":"validation","validationCode":"fn view_source_ok(auth: &Auth) -> bool {\n    auth.view.auth().map_or(false, |s| s.is_regular() || s.kind.is_sftp())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always source view auth from `url.physical().auth()` of a concrete local/SFTP URL.","Never stack views on views or views on hubs.","Validate view sources at construction time, not only at use time."],"tags":["auth","validation","view","rust"],"backgroundTag":"invalid-argument-value","analyzedSha":"8ebf930f1796ae2076b7d6b0c5e93a1002c18134","analyzedAt":"2026-09-09T22:26:16.379Z","contentChangedAt":"2026-09-09T22:26:16.379Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}