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
- For local paths, pass a plain absolute path like /mnt/media (no scheme) - that never fails to parse
- For cloud paths, use a scheme CloudServiceType::from_scheme recognizes (e.g. s3://bucket/key)
- For content:// URIs, ensure the remainder is a valid UUID
- 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
- Plain absolute local paths never fail from_uri - prefer them for local locations
- Keep a list of supported cloud schemes in sync with CloudServiceType::from_scheme
- Validate scheme-prefixed user input before it reaches location add
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
- Failed to parse cloud path: {}
- Path is required in non-interactive mode
- Path does not exist: {}
- Path must be a directory: {}
- No cloud volumes found. Add a cloud volume first with: sd
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/4e0a2edb763ced03.
Report an issue: GitHub.