{"record":{"id":"53ade1926617c9ac","repo":"databendlabs/databend","slug":"protocol-from-connection-name-name-proto-not","errorCode":null,"errorMessage":"protocol from connection_name={name} ({proto}) not match with uri protocol ({protocol}).","messagePattern":"protocol from connection_name=(.+?) \\((.+?)\\) not match with uri protocol \\((.+?)\\)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/sql/src/planner/binder/location.rs","lineNumber":571,"sourceCode":"    parse_uri_location_resolved(l, parts).await\n}\n\npub fn apply_uri_connection(\n    l: &mut UriLocation,\n    name: &str,\n    conn: UserDefinedConnection,\n) -> Result<()> {\n    let protocol = l.protocol.parse::<Scheme>()?;\n    let proto = conn.storage_type.parse::<Scheme>().map_err(|err| {\n        Error::new(\n            ErrorKind::InvalidInput,\n            anyhow!(\"input connection is not a valid protocol: {err:?}\"),\n        )\n    })?;\n    if proto != protocol {\n        return Err(Error::new(\n            ErrorKind::InvalidInput,\n            anyhow!(\n                \"protocol from connection_name={name} ({proto}) not match with uri protocol ({protocol}).\"\n            ),\n        ));\n    }\n    l.connection.check().map_err(|_| {\n        Error::new(\n            ErrorKind::InvalidInput,\n            anyhow!(\"connection_name can not be used with other connection options\"),\n        )\n    })?;\n    l.connection = Connection::new(conn.storage_params);\n\n    Ok(())\n}\n\nasync fn parse_uri_location_resolved(\n    l: &mut UriLocation,\n    parts: ParsedUriLocation,","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/sql/src/planner/binder/location.rs#L553-L589","documentation":"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.","triggerScenarios":"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.","commonSituations":"Reusing a connection object across different cloud backends; copy-pasting stage DDL and changing the URL but not the CONNECTION_NAME.","solutions":["Use a CONNECTION_NAME whose storage type matches the URI scheme (s3 URL with an s3 connection, etc.)","Create a new named connection for the other storage protocol","Change the URI scheme to match the referenced connection's protocol"],"exampleFix":"-- before\nCREATE STAGE s URL='gcs://bucket/path/' CONNECTION_NAME='my_s3_conn';\n-- after\nCREATE STAGE s URL='s3://bucket/path/' CONNECTION_NAME='my_s3_conn';","handlingStrategy":"validation","validationCode":"let uri_proto = url::Url::parse(storage_url)?.scheme();\nlet conn_proto = get_connection(name)?.storage_type;\nif uri_proto != conn_proto {\n    return Err(format!(\"connection {name} is {conn_proto}, URI is {uri_proto}\"));\n}","typeGuard":null,"tryCatchPattern":"match err.kind() { ErrorKind::InvalidInput if msg.contains(\"not match with uri protocol\") => /* use a matching connection */, _ => return Err(err) }","preventionTips":["Keep one named connection per storage protocol and name them accordingly","When changing a stage URL, review the referenced CONNECTION_NAME","Validate scheme-vs-connection pairing in IaC/templating"],"tags":["connection","url","scheme","mismatch"],"backgroundTag":"incompatible-source-type","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}