pub unsafe fn list_duckdb_secrets(
connection: duckdb_connection,
) -> Result<Vec<DuckDbSecretInfo>, ExtensionError>Expand description
Lists the secrets configured in the DuckDB instance behind connection.
This queries the duckdb_secrets() table function, which is the only route
an extension has: the extension C API has no secret functions at all.
§What it returns, and what it can leak
DuckDB redacts the fields each secret type declares sensitive. A secret
created as (TYPE s3, KEY_ID 'AKIA…', SECRET 'super-secret-value') comes
back as …;key_id=AKIA…;secret=redacted. Use this to discover which
secrets exist and what they cover — to choose a scope, or to tell the user
which one is missing — not to authenticate with them.
Redaction is per field, so secret_string can still hold a credential: an
http secret’s extra_http_headers (an Authorization header, say) is
rendered in full up to DuckDB 1.5.x (2.0.0 redacts it), as is every field of a secret type that declares none
sensitive, and on DuckDB 1.4.4 and 1.5.0 even an http secret’s
bearer_token. Do not log secret_string; DuckDbSecretInfo’s Debug omits
it for that reason.
§Errors
Returns ExtensionError if the query fails.
§Safety
connection must be a valid, open duckdb_connection.
§Example
use quack_rs::secrets::list_duckdb_secrets;
// SAFETY: `con` is a valid, open connection.
let secrets = unsafe { list_duckdb_secrets(con) }?;
if !secrets.iter().any(|s| s.secret_type == "s3") {
eprintln!("no S3 secret configured; run CREATE SECRET (TYPE s3, ...)");
}