spacedriveapp/spacedrive · error · anyhow::Error

Invalid path: {}

Error message

Invalid path: {}

What it means

Wraps the SdPathParseError returned by SdPath::from_uri() (core/src/domain/addressing.rs:419). from_uri splits on '://'; a string without a scheme is always accepted as a local Physical path, so this error only comes from scheme-prefixed URIs: UnknownScheme (scheme not a recognized CloudServiceType), InvalidContentId (content:// with a bad UUID), or InvalidSidecar* variants (sidecar:// with a malformed path/kind/format).

Source

Thrown at apps/cli/src/domains/location/args.rs:47

	/// Display name for the location
	#[arg(long)]
	pub name: Option<String>,

	/// Indexing mode
	#[arg(long, value_enum)]
	pub mode: Option<IndexModeArg>,
}

impl LocationAddArgs {
	/// Build an SdPath from the args (non-interactive mode)
	pub fn build_sd_path(&self) -> anyhow::Result<SdPath> {
		let path_str = self
			.path
			.as_ref()
			.ok_or_else(|| anyhow::anyhow!("Path is required in non-interactive mode"))?;

		// Use SdPath::from_uri() to parse service-based paths or local paths
		SdPath::from_uri(path_str).map_err(|e| anyhow::anyhow!("Invalid path: {}", e))
	}

	/// Check if interactive mode should be triggered
	pub fn is_interactive(&self) -> bool {
		self.path.is_none()
	}
}

#[derive(Args, Debug)]
pub struct LocationRemoveArgs {
	pub location_id: Uuid,
	#[arg(long, short = 'y', default_value_t = false)]
	pub yes: bool,
}

impl From<LocationRemoveArgs> for LocationRemoveInput {
	fn from(args: LocationRemoveArgs) -> Self {
		Self {

View on GitHub (pinned to 6dfeccf211)

Solutions

  1. For local paths, pass a plain absolute path like /mnt/media (no scheme) - that never fails to parse
  2. For cloud paths, use a scheme CloudServiceType::from_scheme recognizes (e.g. s3://bucket/key)
  3. For content:// URIs, ensure the remainder is a valid UUID
  4. For sidecar:// URIs, use the form sidecar://<uuid>/<kind>/<variant>.<ext> with kind in thumbs|proxies|embeddings|ocr|transcript

Example fix

// before
SdPath::from_uri(path_str).map_err(|e| anyhow::anyhow!("Invalid path: {}", e))

// after: reject unsupported schemes with a specific hint
let scheme = path_str.split_once("://").map(|(s, _)| s);
if let Some(s) = scheme {
    anyhow::ensure!(
        matches!(s, "local" | "content" | "sidecar") || sd_core::volume::backend::CloudServiceType::from_scheme(s).is_some(),
        "Unsupported path scheme '{}'" ,
        s
    );
}
SdPath::from_uri(path_str).map_err(|e| anyhow::anyhow!("Invalid path: {}", e))
Defensive patterns

Strategy: validation

Validate before calling

fn uri_scheme(uri: &str) -> Option<&str> {
    uri.split_once("://").map(|(s, _)| s)
}

// Only scheme-prefixed strings can fail; validate the scheme first
if let Some(s) = uri_scheme(path_str) {
    anyhow::ensure!(
        matches!(s, "local" | "content" | "sidecar")
            || sd_core::volume::backend::CloudServiceType::from_scheme(s).is_some(),
        "unsupported scheme '{}' - use a plain path or a recognized cloud scheme",
        s
    );
}
let sd_path = SdPath::from_uri(path_str)?;

Type guard

fn parses_as_sd_path(uri: &str) -> bool {
    SdPath::from_uri(uri).is_ok()
}

Try / catch

match SdPath::from_uri(path_str) {
    Ok(p) => p,
    Err(SdPathParseError::UnknownScheme) => anyhow::bail!("'{}' is not a supported cloud scheme; pass a local path without a scheme", path_str),
    Err(SdPathParseError::InvalidContentId) => anyhow::bail!("content:// URI needs a valid UUID"),
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Passing --path gdrive://my-bucket/photos when the scheme is not a supported cloud service; content://not-a-uuid; sidecar://<uuid>/thumbs with missing extension or wrong kind directory.

Common situations: Assuming a cloud provider is supported because its URI looks standard; copy-pasting sidecar URIs with truncated variants; version drift where a scheme was added/removed from CloudServiceType::from_scheme.

Related errors


AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16). Data as JSON: /api/errors/4e0a2edb763ced03. Report an issue: GitHub.