quickwit-oss/quickwit · error

failed to normalize URI: tilde expansion is only partially…

Error message

failed to normalize URI: tilde expansion is only partially supported

What it means

During normalization in `Uri::parse_str`, a `~`-relative path was encountered (e.g. `~user/...`). Only expansion of a bare `~` to the home directory is supported; per-user tilde prefixes like `~otheruser` cannot be resolved portably, so normalization aborts.

Solutions

  1. Replace the tilde with an absolute path, e.g. `/home/user/...`
  2. Use a bare `~` (current user's home) only when it applies
  3. Set the path via environment variables expanded by the shell
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at quickwit/quickwit-common/src/uri.rs:274 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08). Data as JSON: /api/errors/f9b878d436048afe. Report an issue: GitHub.

Appendix: source

Thrown at quickwit/quickwit-common/src/uri.rs:274

    /// A `file://` protocol is assumed if not specified.
    /// File URIs are resolved (normalized) relative to the current working directory
    /// unless an absolute path is specified.
    /// Handles special characters such as `~`, `.`, `..`.
    fn parse_str(uri_str: &str) -> anyhow::Result<Self> {
        // CAUTION: Do not display the URI in error messages to avoid leaking credentials.
        if uri_str.is_empty() {
            bail!("failed to parse empty URI");
        }
        let (protocol, mut path) = match uri_str.split_once(PROTOCOL_SEPARATOR) {
            None => (Protocol::File, uri_str.to_string()),
            Some((protocol, path)) => (Protocol::from_str(protocol)?, path.to_string()),
        };
        if protocol == Protocol::File {
            if path.starts_with('~') {
                // We only accept `~` (alias to the home directory) and `~/path/to/something`.
                // If there is something following the `~` that is not `/`, we bail.
                if path.len() > 1 && !path.starts_with("~/") {
                    bail!("failed to normalize URI: tilde expansion is only partially supported");
                }

                let home_dir_path = home::home_dir()
                    .context("failed to normalize URI: could not resolve home directory")?
                    .to_string_lossy()
                    .to_string();

                path.replace_range(0..1, &home_dir_path);
            }
            if Path::new(&path).is_relative() {
                let current_dir = env::current_dir().context(
                    "failed to normalize URI: could not resolve current working directory. the \
                     directory does not exist or user has insufficient permissions",
                )?;
                path = current_dir.join(path).to_string_lossy().to_string();
            }
            path = normalize_path(Path::new(&path))
                .to_string_lossy()

View on GitHub (pinned to a39730c5cd)