sxyazi/yazi · error
at least one of `url` or `mime` must be specified
Error message
at least one of `url` or `mime` must be specified
What it means
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.
Source
Thrown at yazi-config/src/selector.rs:38
let shadow = Shadow::deserialize(deserializer)?;
Self::new(shadow.url, shadow.mime).map_err(de::Error::custom)
}
}
impl DeserializeOverWith for Selector {
fn deserialize_over_with<'de, D: Deserializer<'de>>(
self,
deserializer: D,
) -> Result<Self, D::Error> {
let new = Self::deserialize(deserializer)?;
Self::new(new.url.or(self.url), new.mime.or(self.mime)).map_err(de::Error::custom)
}
}
impl Selector {
fn new(url: Option<Pattern>, mime: Option<Pattern>) -> Result<Self> {
ensure!(url.is_some() || mime.is_some(), "at least one of `url` or `mime` must be specified");
Ok(Self { url, mime })
}
}
impl Selectable for Selector {
fn url_pat(&self) -> Option<&Pattern> { self.url.as_ref() }
fn mime_pat(&self) -> Option<&Pattern> { self.mime.as_ref() }
}
impl Mixable for Selector {
fn any_file(&self) -> bool { self.url_pat().is_some_and(|p| p.any_file()) }
fn any_dir(&self) -> bool { self.url_pat().is_some_and(|p| p.any_dir()) }
}
View on GitHub (pinned to 5f901b886b)
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
Example fix
# before
{ } # empty selector
// after
{ url = "*/src/**" } # or { mime = "image/*" } Defensive patterns
Strategy: validation
Validate before calling
-- validate a selector table before writing it to config / merging local function valid_selector(s) return type(s) == 'table' and (s.url ~= nil or s.mime ~= nil) end assert(valid_selector(sel), 'selector needs url or mime')
Type guard
fn is_valid_selector(s: &toml::Value) -> bool {
s.get("url").is_some() || s.get("mime").is_some()
} Try / catch
match toml::from_str::<Config>(raw) {
Ok(c) => c,
Err(e) => { eprintln!("config invalid: {e}"); Default::default() }
} Prevention
- 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
When it happens
Trigger: 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)`).
Common situations: 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.
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
- Invalid condition: {expr}
- Invalid URL pattern: scheme is empty
- Cannot construct system event
- Kind `{kind}` must be in kebab-case
- invalid file type: {value:04o}
AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02).
Data as JSON: /api/errors/e45c1e7d3c23392d.
Report an issue: GitHub.