databendlabs/databend · error

protocol from connection_name=

Error message

protocol from connection_name={name} ({proto}) not match with uri protocol ({protocol}).

What it means

When applying a named connection to a URI location, the connection's storage protocol must match the protocol of the URI being resolved. If conn.storage_type parses to a different Scheme than the URI's protocol, this InvalidInput error is thrown to prevent mixing credentials/config from one storage backend with a different backend's URI.

Solutions

  1. Use a CONNECTION_NAME whose storage type matches the URI scheme (s3 URL with an s3 connection, etc.)
  2. Create a new named connection for the other storage protocol
  3. Change the URI scheme to match the referenced connection's protocol

Example fix

-- before
CREATE STAGE s URL='gcs://bucket/path/' CONNECTION_NAME='my_s3_conn';
-- after
CREATE STAGE s URL='s3://bucket/path/' CONNECTION_NAME='my_s3_conn';
Defensive patterns

Strategy: validation

Validate before calling

let uri_proto = url::Url::parse(storage_url)?.scheme();
let conn_proto = get_connection(name)?.storage_type;
if uri_proto != conn_proto {
    return Err(format!("connection {name} is {conn_proto}, URI is {uri_proto}"));
}

Try / catch

match err.kind() { ErrorKind::InvalidInput if msg.contains("not match with uri protocol") => /* use a matching connection */, _ => return Err(err) }

Prevention

When it happens

Trigger: STAGE with URL='s3://bucket/path/' CONNECTION_NAME='my_gcs_conn' where the named connection was created for GCS (storage_type='gcs'), or any cross-protocol combination.

Common situations: Reusing a connection object across different cloud backends; copy-pasting stage DDL and changing the URL but not the CONNECTION_NAME.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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

Appendix: source

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

    parse_uri_location_resolved(l, parts).await
}

pub fn apply_uri_connection(
    l: &mut UriLocation,
    name: &str,
    conn: UserDefinedConnection,
) -> Result<()> {
    let protocol = l.protocol.parse::<Scheme>()?;
    let proto = conn.storage_type.parse::<Scheme>().map_err(|err| {
        Error::new(
            ErrorKind::InvalidInput,
            anyhow!("input connection is not a valid protocol: {err:?}"),
        )
    })?;
    if proto != protocol {
        return Err(Error::new(
            ErrorKind::InvalidInput,
            anyhow!(
                "protocol from connection_name={name} ({proto}) not match with uri protocol ({protocol})."
            ),
        ));
    }
    l.connection.check().map_err(|_| {
        Error::new(
            ErrorKind::InvalidInput,
            anyhow!("connection_name can not be used with other connection options"),
        )
    })?;
    l.connection = Connection::new(conn.storage_params);

    Ok(())
}

async fn parse_uri_location_resolved(
    l: &mut UriLocation,
    parts: ParsedUriLocation,

View on GitHub (pinned to 288d84d76e)