databendlabs/databend · error

value for enable_virtual_host_style is invalid

Error message

value for enable_virtual_host_style is invalid: {err:?}

What it means

When binding an S3-style URI location (e.g. CREATE CONNECTION / STAGE with CONNECTION options), Databend parses the enable_virtual_host_style connection option with Rust's bool::from_str, which only accepts exactly "true" or "false". If the option is present but is any other string, the parse fails and this InvalidInput error is thrown from parse_s3_params. It means the option value is not a valid boolean literal.

Solutions

  1. Change the option value to exactly 'true' or 'false' (lowercase, no quotes variation)
  2. Remove the ENABLE_VIRTUAL_HOST_STYLE option entirely if you want the default (false)
  3. Check for variable interpolation/templating that may have substituted an unexpected value

Example fix

-- before
CREATE STAGE s URL='s3://bucket/' CONNECTION=(ENABLE_VIRTUAL_HOST_STYLE='yes');
-- after
CREATE STAGE s URL='s3://bucket/' CONNECTION=(ENABLE_VIRTUAL_HOST_STYLE='true');
Defensive patterns

Strategy: validation

Validate before calling

let v = opts.get("enable_virtual_host_style").unwrap_or("false");
if !matches!(v, "true" | "false") {
    return Err(format!("enable_virtual_host_style must be 'true' or 'false', got {v:?}"));
}

Type guard

fn is_valid_bool_str(s: &str) -> bool { matches!(s, "true" | "false") }

Prevention

When it happens

Trigger: Executing SQL like CREATE STAGE ... URL='s3://bucket/path' CONNECTION=(ENABLE_VIRTUAL_HOST_STYLE = 'yes') or any value other than exactly true/false (case-sensitive): '1', 'True', 'on', empty string.

Common situations: Copy-pasting config from other tools that accept yes/1/True; shell/templating injecting an unset variable leaving an empty or junk value; typos like 'ttrue'.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

        }
    }
    .to_string();

    let master_key = l.connection.get("master_key").cloned().unwrap_or_default();

    let enable_virtual_host_style = {
        if let Some(s) = l.connection.get("enable_virtual_host_style") {
            s
        } else {
            "false"
        }
    }
    .to_string()
    .parse()
    .map_err(|err| {
        Error::new(
            ErrorKind::InvalidInput,
            anyhow!("value for enable_virtual_host_style is invalid: {err:?}"),
        )
    })?;

    let role_arn = {
        if let Some(role) = l.connection.get("role_arn") {
            role
        } else if let Some(role) = l.connection.get("aws_role_arn") {
            role
        } else {
            ""
        }
    }
    .to_string();

    let external_id = {
        if let Some(id) = l.connection.get("external_id") {
            id
        } else if let Some(id) = l.connection.get("aws_external_id") {

View on GitHub (pinned to 288d84d76e)