Secret types and credential discovery
A worker that talks to an API needs credentials, and DuckDB already has a place for them:
secrets. A worker declares a secret type — a name, a description, and an Apache Arrow
schema whose fields are the keys of CREATE SECRET. ATTACH registers the type with DuckDB, users
create instances of it, and each function that declares a requirement on the type receives the
resolved values at bind time.
This page is about the declaration itself: how to document it so a user, a directory listing, or an agent can work out what credentials the worker needs, which keys are required, and where to get them — without reading the worker’s source. It applies to every SDK; the per-language “settings and secrets” how-tos (Go, C#) cover the registration calls themselves.
The declaration
Section titled “The declaration”A secret type has three parts, all already on the wire:
name— theTYPEinCREATE SECRET … (TYPE name, …).description— the service and kind of credential, e.g. “Microsoft Entra app-only client credentials for Azure ARM / Microsoft Graph”.- A parameters schema — one Arrow field per key. The field’s type becomes the key’s DuckDB type.
DuckDB’s own duckdb_secret_types() only shows the name. Everything else is carried in the schema’s
metadata and read back through vgi_secret_types().
Metadata keys
Section titled “Metadata keys”Field and schema metadata follow the same vgi_* convention as
function arguments. All are
UTF-8 strings and presence-only.
| Key | On | Value | Meaning |
|---|---|---|---|
redact | field | “true” | Mask the value in duckdb_secrets(), SHOW SECRETS and error messages. Mark every credential. |
vgi_doc | field | description | What the value is and where to find it — “Directory (tenant) ID from the app registration’s Overview page”. |
vgi_required | field | “true” | CREATE SECRET must supply this key. |
vgi_doc_url | schema | http(s) URL | The page that explains how to obtain the credentials: sign-up, app registration, roles or scopes to grant. |
Arrow builders default a field’s nullability differently from one SDK to the next, so reading
nullable = false as “required” would silently change the meaning of secret types that already
exist. vgi_required is explicit and opt-in.
Extensions that predate these keys read only redact and ignore the rest, so a worker can add them
now without breaking anyone.
Declaring it
Section titled “Declaring it”SecretTypeSpec(
name="acme",
description="API credentials for the Acme data service",
schema=pa.schema(
[
pa.field("api_key", pa.string(), metadata={
"redact": "true",
"vgi_required": "true",
"vgi_doc": "API key from Settings → API keys in the Acme console",
}),
pa.field("endpoint", pa.string(), metadata={
"vgi_doc": "Base URL; defaults to https://api.acme.example",
}),
],
metadata={"vgi_doc_url": "https://docs.acme.example/api-keys"},
),
)
vgi.SecretTypeSpec{
Name: "acme",
Description: "API credentials for the Acme data service",
Schema: arrow.NewSchema([]arrow.Field{
{Name: "api_key", Type: arrow.BinaryTypes.String, Metadata: arrow.NewMetadata(
[]string{"redact", "vgi_required", "vgi_doc"},
[]string{"true", "true", "API key from Settings → API keys in the Acme console"})},
{Name: "endpoint", Type: arrow.BinaryTypes.String, Metadata: arrow.NewMetadata(
[]string{"vgi_doc"}, []string{"Base URL; defaults to https://api.acme.example"})},
}, func() *arrow.Metadata {
md := arrow.NewMetadata([]string{"vgi_doc_url"}, []string{"https://docs.acme.example/api-keys"})
return &md
}()),
}
const ACME_SECRET: SecretTypeDescriptor = {
name: "acme",
description: "API credentials for the Acme data service",
schema: new Schema(
[
new Field("api_key", new Utf8(), true, new Map([
["redact", "true"],
["vgi_required", "true"],
["vgi_doc", "API key from Settings → API keys in the Acme console"],
])),
new Field("endpoint", new Utf8(), true, new Map([
["vgi_doc", "Base URL; defaults to https://api.acme.example"],
])),
],
new Map([["vgi_doc_url", "https://docs.acme.example/api-keys"]]),
),
};
Rust, Java and C# set the same keys through their Arrow field and schema metadata maps.
Reading it back: vgi_secret_types()
Section titled “Reading it back: vgi_secret_types()”vgi_secret_types(catalog := NULL) returns one row per secret type each attached VGI catalog
declares. Pass catalog := '…' to look at one attachment.
| Column | Type | Contents |
|---|---|---|
catalog_name | VARCHAR | The attached catalog. |
secret_type | VARCHAR | The TYPE name. |
description | VARCHAR | The declaration’s description. |
doc_url | VARCHAR | vgi_doc_url, or NULL. |
parameters | STRUCT(name, type, required, redact, description)[] | Every key, in declaration order. |
required_by | VARCHAR[] | Schema-qualified functions that declare a requirement on this type. |
ATTACH 'acme' AS acme (TYPE vgi, LOCATION 'github-auto://acme/vgi-acme');
SELECT secret_type, description, doc_url, required_by
FROM vgi_secret_types(catalog := 'acme');
SELECT p.name, p.type, p.required, p.redact, p.description
FROM vgi_secret_types(catalog := 'acme'), unnest(parameters) AS t(p);
That is enough to render a ready-to-fill template — with redacted keys read from the environment rather than typed into SQL:
CREATE SECRET acme (
TYPE acme,
API_KEY getenv('ACME_API_KEY'), -- required, redacted
ENDPOINT 'https://api.acme.example' -- optional
);
vgi_secret_types() and the vgi_doc / vgi_required / vgi_doc_url keys ship in the next
vgi extension release. Extension-reserved types such as iroh are never listed.
Lint checks
Section titled “Lint checks”vgi-lint reads vgi_secret_types() when the
extension provides it, and stays silent on extensions that don’t:
- VGI1010 — the secret type has a meaningful description.
- VGI1011 — every parameter carries
vgi_doc. - VGI1012 — the type links to
vgi_doc_url(info). - VGI1013 — a parameter named like a credential (
*secret*,*token*,*password*,*api_key*…) is markedredact. Identifiers such asclient_idare exempt.
A related rule, VGI1003, looks the other way: an endpoint or other connection setting that every
example passes with the same value usually belongs in an attach option, set once at ATTACH,
rather than in a secret or a function argument.