{"record":{"id":"e45c1e7d3c23392d","repo":"sxyazi/yazi","slug":"at-least-one-of-url-or-mime-must-be-specified","errorCode":null,"errorMessage":"at least one of `url` or `mime` must be specified","messagePattern":"at least one of `url` or `mime` must be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-config/src/selector.rs","lineNumber":38,"sourceCode":"\n\t\tlet shadow = Shadow::deserialize(deserializer)?;\n\t\tSelf::new(shadow.url, shadow.mime).map_err(de::Error::custom)\n\t}\n}\n\nimpl DeserializeOverWith for Selector {\n\tfn deserialize_over_with<'de, D: Deserializer<'de>>(\n\t\tself,\n\t\tdeserializer: D,\n\t) -> Result<Self, D::Error> {\n\t\tlet new = Self::deserialize(deserializer)?;\n\t\tSelf::new(new.url.or(self.url), new.mime.or(self.mime)).map_err(de::Error::custom)\n\t}\n}\n\nimpl Selector {\n\tfn new(url: Option<Pattern>, mime: Option<Pattern>) -> Result<Self> {\n\t\tensure!(url.is_some() || mime.is_some(), \"at least one of `url` or `mime` must be specified\");\n\t\tOk(Self { url, mime })\n\t}\n}\n\nimpl Selectable for Selector {\n\tfn url_pat(&self) -> Option<&Pattern> { self.url.as_ref() }\n\n\tfn mime_pat(&self) -> Option<&Pattern> { self.mime.as_ref() }\n}\n\nimpl Mixable for Selector {\n\tfn any_file(&self) -> bool { self.url_pat().is_some_and(|p| p.any_file()) }\n\n\tfn any_dir(&self) -> bool { self.url_pat().is_some_and(|p| p.any_dir()) }\n}\n","sourceCodeStart":20,"sourceCodeEnd":54,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-config/src/selector.rs#L20-L54","documentation":"Selector::new requires that at least one of the url or mime patterns is Some, since a selector with neither predicate would match nothing meaningful (or be ambiguous). It is also invoked from the Deserialize impl, so an invalid TOML selector entry fails deserialization with this message.","triggerScenarios":"Deserializing a selector table in config that omits both `url` and `mime` keys, or calling Selector::new(None, None) directly (e.g., merging two selectors where both fields are None after `new.url.or(self.url)` / `new.mime.or(self.mime)`).","commonSituations":"A yazi.toml rule block like [[opener]]-adjacent selector/filter config with an empty selector table `{ }`, or a typo'd key (e.g., `urls` instead of `url`) so neither recognized field is present.","solutions":["Add a `url` pattern to the selector table","Add a `mime` pattern to the selector table","Check key spelling (`url`/`mime`) in the config entry"],"exampleFix":"# before\n{ } # empty selector\n// after\n{ url = \"*/src/**\" } # or { mime = \"image/*\" }","handlingStrategy":"validation","validationCode":"-- validate a selector table before writing it to config / merging\nlocal function valid_selector(s)\n  return type(s) == 'table' and (s.url ~= nil or s.mime ~= nil)\nend\nassert(valid_selector(sel), 'selector needs url or mime')","typeGuard":"fn is_valid_selector(s: &toml::Value) -> bool {\n    s.get(\"url\").is_some() || s.get(\"mime\").is_some()\n}","tryCatchPattern":"match toml::from_str::<Config>(raw) {\n    Ok(c) => c,\n    Err(e) => { eprintln!(\"config invalid: {e}\"); Default::default() }\n}","preventionTips":["Never leave a selector table empty in config","Check key spelling: `url` and `mime` only","Validate TOML after editing with `ya` or a TOML linter"],"tags":["config","validation","selector","deserialization"],"backgroundTag":"schema-validation-failed","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}