Credentials

Sources, streams, sinks and queues read a password, or any other property, with SECRET(provider, name [, key]). The registry stores the reference, never the value. featuremeshd, or the Python process that runs the engine, reads the value when it connects.

CallReads
SECRET('env', 'PG_PASSWORD')the environment variable PG_PASSWORD of the process that connects
SECRET('file', '/run/secrets/pg_password')a file's content, without its trailing newline: Docker and Kubernetes secrets
SECRET('file', '/run/secrets/db.json', 'password')the field password of a file holding a JSON object, the shape secret managers often mount

A database source's username and password properties replace the DSN's own user and password, encoded for the DSN, so a password may hold any character:

POSTGRES_CONN := SOURCE_DB(
    'postgresql://db.internal:5432/shop?sslmode=require'
    WITH (
        username = SECRET('file', '/run/secrets/db.json', 'username'),
        password = SECRET('file', '/run/secrets/db.json', 'password'),
        tables = ARRAY('orders')
    )
)

An HTTP source puts its token in headers ( Authenticated calls ). A stream takes PASSWORD and SSL_KEY_PASSWORD ( Connections ). A sink or a queue takes PASSWORD ( Properties ).

A rotated secret applies only once featuremeshd reads it again, at a time that depends on the kind ( Rotate credentials and certificates ).

An unreadable secret

A secret the engine cannot read fails its own definition, not the recompile. Here the environment variable is not set:

FeatureQL
CREATE OR REPLACE FEATURE FM.TUTORIALS.EXTERNAL_JDBC.UNSET_SECRET_CONN AS
    SOURCE_DB(
        'postgresql://featuremesh@host.docker.internal:25432/featuremesh?sslmode=disable'
        WITH (
            password = SECRET('env', 'FEATUREMESH_DOCS_UNSET_PASSWORD'),
            tables=ARRAY['serving_slt_customers']
        )
    );
Result
feature_name VARCHARstatus VARCHARmessage VARCHAR
FM.TUTORIALS.EXTERNAL_JDBC.UNSET_SECRET_CONNCREATEDFeature created as not exists

FeatureQL
RECOMPILE SERVING;
Result
FEATURE VARCHARKIND VARCHARSTATUS VARCHARMESSAGE VARCHARSINCE VARCHAR
FM.TUTORIALS.EXTERNAL_JDBC.POSTGRES_CONNSOURCE_DBLOADED
FM.TUTORIALS.EXTERNAL_JDBC.UNSET_SECRET_CONNSOURCE_DBERRORdatasource: config parse failed: SECRET('env', 'FEATUREMESH_DOCS_UNSET_PASSWORD'): the environment variable is not set

The source is in ERROR and nothing is served from it. The message names the secret, never a value, and the other sources are not affected. A stream, a sink or a queue loads, and its hook is STALLED until the secret can be read ( A missing secret, by kind ). How to fix it is in Deploy .

SECRET() is read only in the properties of a source, a stream or a sink, where the engine resolves it. A query that reads it elsewhere is refused, so a secret never ends up in a result:

FeatureQL
RETURN
    pg_password := SECRET('env', 'FEATUREMESH_DEMOS_PG_PASSWORD')
;
Result
ERROR UE/SECRET-OUTSIDE-SOURCE

No password in clear

A password written in clear, in a DSN, a URL, password, PASSWORD or SSL_KEY_PASSWORD, is stored by the registry and shown with the definition. The hosted platform refuses it with SOURCE-INLINE-PASSWORD. A local registry and the Python library store it with a warning.

FeatureQL
CREATE OR REPLACE FEATURE FM.TUTORIALS.HOOK_REF.BAD AS SINK('postgresql://fm:s3cret@postgres:5432/fm' TABLE 'per_minute' KEY (merchant_id) WITH (MODE = 'latest'));
Result
ERROR UE/SOURCE-INLINE-PASSWORD The sink FM.TUTORIALS.HOOK_REF.BAD holds a password written in clear, which the registry stores. Read it from the serving engine's environment instead: password = SECRET('env', 'NAME') or SECRET('file', '/path').

Obvious placeholders pass with a warning, so prototypes and tests stay easy:

  • an empty value, or only x, * or .;
  • a value starting with fake_, test_, dummy_ or example_;
  • a <...> placeholder, or an ${VAR} reference;
  • one of password, secret, changeme, test, example, dummy, fake, demo, postgres, admin, featuremesh, local.