nautechsystems/nautilus_trader · error · anyhow::Error

Invalid ABFS URI: cannot extract account from host

Error message

Invalid ABFS URI: cannot extract account from host

What it means

When building an Azure ABFS (ADLS Gen2) object store, the account name is parsed from the URI host (the part before the first dot, e.g. 'myaccount' in myaccount.dfs.core.windows.net). If the host splits in a way that yields no first segment, the parser throws this error. In practice this indicates a malformed ABFS URI host.

Source

Thrown at crates/persistence/src/parquet.rs:896

    let azure_store = builder.build()?;
    Ok((Arc::new(azure_store), path, uri.to_string()))
}

/// Creates an Azure object store from an `abfs://` URI with options.
#[cfg(feature = "cloud")]
fn create_abfs_store(
    uri: &str,
    storage_options: Option<AHashMap<String, String>>,
) -> anyhow::Result<(Arc<dyn ObjectStore>, String, String)> {
    let (url, path) = parse_url_and_path(uri)?;
    let host = extract_host(&url, "Invalid ABFS URI: missing host")?;

    // Extract account from host (account.dfs.core.windows.net)
    let account = host
        .split('.')
        .next()
        .ok_or_else(|| anyhow::anyhow!("Invalid ABFS URI: cannot extract account from host"))?;

    // Extract container from username part
    let container = url
        .username()
        .split('@')
        .next()
        .ok_or_else(|| anyhow::anyhow!("Invalid ABFS URI: missing container"))?;

    let mut builder = object_store::azure::MicrosoftAzureBuilder::new()
        .with_account(account)
        .with_container_name(container);

    // Apply storage options if provided (same as Azure store)
    if let Some(options) = storage_options {
        for (key, value) in options {
            match key.as_str() {
                "account_name" => {
                    builder = builder.with_account(&value);

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use full ABFS URI format: abfs[s]://<container>@<account>.dfs.core.windows.net/<path>
  2. Verify the host portion is present and non-empty in the URI string
  3. Print/log the parsed url.host_str() before calling to debug what the URL crate sees
  4. Escape or percent-encode special characters in account/container names

Example fix

// before
let path = "abfs:///data/file.parquet"; // missing host
// after
let path = "abfs://container@myaccount.dfs.core.windows.net/data/file.parquet";
Defensive patterns

Strategy: validation

Validate before calling

let url = url::Url::parse(path)?;
anyhow::ensure!(url.host_str().map_or(false, |h| h.contains('.') && !h.starts_with('.')),
    "ABFS URI host must be <account>.dfs.core.windows.net, got {:?}", url.host_str());

Type guard

fn is_valid_abfs_uri(s: &str) -> bool {
    url::Url::parse(s).ok()
        .and_then(|u| u.host_str().map(|h| h.to_string()))
        .map_or(false, |h| h.split('.').next().map_or(false, |a| !a.is_empty()))
}

Try / catch

match create_object_store_location_from_path(path, None) {
    Ok(loc) => loc,
    Err(e) => return Err(e.context(format!("check ABFS URI format: {path}"))),
}

Prevention

When it happens

Trigger: Calling create_object_store_location_from_path with an abfs:// or abfss:// URI whose host is empty or does not follow account.dfs.core.windows.net format.

Common situations: Typos like 'abfs:///container/path' (no host); custom on-prem endpoint hosts; URI built programmatically with a missing account.

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 nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/f0a042e662f0a062. Report an issue: GitHub.