Standard Library

config

import config reads declared secrets and public config values from Via's config server. The runtime fetches values over the workload identity issued to the container at launch, so application code does not handle credentials or know the config server's address.

Local versus deployed behavior

EnvironmentBehavior
Deployed on ViaValues come from the bound config server.
vary run locallyReads env vars for declared keys.
TestsUse the testing helpers; no production values.

On Via, the bootstrap variables (VARY_CONFIG_URL, VARY_CONFIG_TOKEN_PATH, VARY_ENVIRONMENT) are set at container launch and identify the app to the config server. Local vary run falls back to plain environment variables for declared keys; missing keys raise ConfigMissingError. Use a local vary.toml [secrets] block to declare development values.

API surface

import config

let db_url = config.secret("DATABASE_URL")
let feature_enabled = config.bool("FEATURE_NEW_FLOW", False)
FunctionReturnsRaises
secret(name)StrAny ConfigError subclass below.
bool(name, default)BoolConfigBadTypeError if not parseable as Bool.

All errors subclass ConfigError, so application code can either catch each subclass specifically (for fall-back behavior) or except ConfigError as e for the generic case.

ErrorCause
ConfigMissingErrorThe key is declared but no value is set.
ConfigUndeclaredErrorKey is not declared in vary.toml.
ConfigPermissionDeniedErrorThe workload identity token was rejected.
ConfigServerUnavailableErrorNetwork failure, timeout, 5xx, or bad bootstrap.
ConfigBadTypeErrorStored value cannot be coerced to the type.

Relation to vary app env and vary app config

SurfaceWhat it controls
vary app env set/rotate/historySecrets read via config.secret(...).
vary app config patch/validate/diff/redeployPublic config read via config.bool(...).
vary.toml [config] and [secrets] blocksDeclarations; undeclared keys are rejected.

Treat every config read as an external call that can fail. Wrap reads in try/except ConfigError at the boundary that has a default policy, not inside business logic deep in the call graph.

← url_policy
metrics →