sxyazi/yazi · error

Invalid URL pattern: scheme is empty

Error message

Invalid URL pattern: scheme is empty

What it means

Yazi's URL pattern parser (yazi-config/src/pattern.rs:130) parses a scheme portion of a glob/match pattern, e.g. `local/path/**` or `remote:bucket`. An empty scheme string means the pattern started with the scheme separator but had nothing before it, so the parser cannot determine which URL namespace the pattern applies to and bails.

Source

Thrown at yazi-config/src/pattern.rs:128

	Any,
	Local,
	Remote,

	Custom(String),
}

impl PatternScheme {
	fn parse(s: &str) -> Result<(Self, usize)> {
		let Some((s, _)) = s.split_once("://") else {
			return Ok((Self::Any, 0));
		};

		let scheme = match s {
			"*" => Self::Any,
			"local" => Self::Local,
			"remote" => Self::Remote,

			"" => bail!("Invalid URL pattern: scheme is empty"),
			other => Self::Custom(other.to_owned()),
		};

		Ok((scheme, s.len() + 3))
	}

	#[inline]
	fn matches(&self, auth: &Auth) -> bool {
		match self {
			Self::Any => true,
			Self::Local => auth.is_local(),
			Self::Remote => auth.is_remote(),
			Self::Custom(name) => auth.scheme == name,
		}
	}
}

// --- Tests

View on GitHub (pinned to 8ebf930f17)

Solutions

  1. Fix the pattern string so it either has a non-empty scheme (e.g. `local/...`, `remote/...`) or no scheme separator at all.
  2. If any scheme should match, use the wildcard `*` as the scheme instead of leaving it empty.
  3. Validate/trim the scheme in code before constructing the pattern, rejecting or defaulting empty values.

Example fix

// before
Pattern::parse("://downloads/**")
// after
Pattern::parse("*/downloads/**")  // or "local/downloads/**"
Defensive patterns

Strategy: validation

Validate before calling

fn valid_scheme(p: &str) -> bool {
    match p.split_once("://") {
        Some((scheme, _)) => !scheme.is_empty(),
        None => true, // no scheme separator is fine
    }
}
assert!(valid_scheme("local/d/**"));
assert!(!valid_scheme("://d/**"));

Prevention

When it happens

Trigger: Calling pattern parsing with a string whose scheme part before the `://` separator is empty, e.g. a pattern like `://foo` or `:*/x` where the portion before the separator is the empty string; the match arm `"" => bail!(...)` fires during `parse`.

Common situations: Hand-written yazi.toml / rules entries with a typo such as a leading `://`, or programmatically built patterns where the scheme variable was empty because it was never set or was stripped by earlier string handling.

Related errors


AI-assisted analysis of sxyazi/yazi@8ebf930f17 (2026-09-09). Data as JSON: /api/errors/1206973590c3671a. Report an issue: GitHub.