databendlabs/databend · error · InvalidInput

input uri is not a valid huggingface uri

Error message

input uri is not a valid huggingface uri

What it means

A Huggingface URI must look like hf://repo-owner/repo-name/path/...; parse_huggingface_params splits the normalized root on the first '/' to extract repo_name and inner root. If the path contains no '/', there is no repo/dataset name and the binder rejects the URI as invalid.

Solutions

  1. Include a path after the repo name: hf://<repo_type>/<repo_name>/<path>/ e.g. hf://opendal/huggingface-testdata/path/.
  2. Verify the URI contains at least repo_name + '/' + path (the split requires a '/').
  3. Check for URL-encoding or trimming that removed the trailing path segment.

Example fix

// before
CREATE STAGE s URL = 'hf://opendal/huggingface-testdata';
// after
CREATE STAGE s URL = 'hf://opendal/huggingface-testdata/data/';
Defensive patterns

Strategy: validation

Validate before calling

// Rust
fn is_valid_hf_uri(url: &str) -> bool {
    url.starts_with("hf://") && url[5..].split_once('/').map_or(false, |(_, rest)| rest.contains('/'))
}

Prevention

When it happens

Trigger: Locations like 'hf://opendaling' or 'hf://opendaling/' — a repo name with no subsequent path segment — used in CREATE STAGE or COPY.

Common situations: Truncating the URI by copying only the repository URL without a trailing path; forgetting the dataset path after the repo; building URIs programmatically with missing path components.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11). Data as JSON: /api/errors/d4492bc2abf133ab. Report an issue: GitHub.

Appendix: source

Thrown at src/query/sql/src/planner/binder/location.rs:467

        network_config: None,
    });

    l.connection
        .check()
        .map_err(|err| Error::new(ErrorKind::InvalidInput, err.to_string()))?;

    Ok(sp)
}

/// Huggingface uri looks like `hf://opendal/huggingface-testdata/path/to/file`.
///
/// We need to parse `huggingface-testdata` from the root.
fn parse_huggingface_params(l: &mut UriLocation, root: String) -> Result<StorageParams> {
    let (repo_name, root) = root
        .trim_start_matches('/')
        .split_once('/')
        .ok_or_else(|| {
            Error::new(
                ErrorKind::InvalidInput,
                "input uri is not a valid huggingface uri",
            )
        })?;

    let sp = StorageParams::Huggingface(StorageHuggingfaceConfig {
        repo_id: format!("{}/{repo_name}", l.name),
        repo_type: l
            .connection
            .get("repo_type")
            .cloned()
            .unwrap_or_else(|| "dataset".to_string()),
        revision: l
            .connection
            .get("revision")
            .cloned()
            .unwrap_or_else(|| "main".to_string()),
        root: root.to_string(),

View on GitHub (pinned to 288d84d76e)