databendlabs/databend · error

endpoint_url is required for storage cos

Error message

endpoint_url is required for storage cos

What it means

When parsing a Tencent Cloud COS URI location, the endpoint_url connection option is required; parse_cos_params throws this InvalidInput error when it is absent. COS endpoints encode the region and app-id, so Databend does not guess a default.

Solutions

  1. Add ENDPOINT_URL to CONNECTION options, e.g. CONNECTION=(ENDPOINT_URL='cos.ap-guangzhou.myqcloud.com')
  2. Use the endpoint matching your COS bucket region and app-id
  3. If you meant S3-compatible access, use an s3:// URL with the COS S3-compatible endpoint

Example fix

-- before
CREATE STAGE s URL='cos://mybucket/path';
-- after
CREATE STAGE s URL='cos://mybucket/path' CONNECTION=(ENDPOINT_URL='cos.ap-guangzhou.myqcloud.com' SECRET_ID='..' SECRET_KEY='..');
Defensive patterns

Strategy: validation

Validate before calling

if url.starts_with("cos://") && !opts.contains_key("endpoint_url") {
    return Err("ENDPOINT_URL is required for cos:// locations".into());
}

Try / catch

match err.kind() { ErrorKind::InvalidInput if msg.contains("endpoint_url") => /* add ENDPOINT_URL and retry */, _ => return Err(err) }

Prevention

When it happens

Trigger: CREATE STAGE / CREATE CONNECTION with URL='cos://bucket/path' and no ENDPOINT_URL in CONNECTION options.

Common situations: Setting up Tencent COS stages without the regional endpoint like cos.ap-guangzhou.myqcloud.com; forgetting the option when copying an S3 stage template.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

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

    });

    l.connection
        .check()
        .map_err(|err| Error::new(ErrorKind::InvalidInput, err.to_string()))?;

    Ok(sp)
}

fn parse_cos_params(l: &mut UriLocation, root: String) -> Result<StorageParams> {
    let endpoint = l
        .connection
        .get("endpoint_url")
        .cloned()
        .map(secure_omission)
        .ok_or_else(|| {
            Error::new(
                ErrorKind::InvalidInput,
                anyhow!("endpoint_url is required for storage cos"),
            )
        })?;
    let sp = StorageParams::Cos(StorageCosConfig {
        endpoint_url: endpoint,
        bucket: l.name.to_string(),
        secret_id: l.connection.get("secret_id").cloned().unwrap_or_default(),
        secret_key: l.connection.get("secret_key").cloned().unwrap_or_default(),
        root,
        network_config: None,
    });

    l.connection
        .check()
        .map_err(|err| Error::new(ErrorKind::InvalidInput, err.to_string()))?;

    Ok(sp)
}

View on GitHub (pinned to 288d84d76e)