tyfigo

Errors

Every problem tyfigo reports, where it is reported and what the error looks like.

tyfigo collects every problem in a config and its layers and reports them together, each as file:line:column - message (code).

Problem codes

CodetscMeaning
parse-errortyfigo1001The file is not valid for its format
duplicate-keytyfigo1002A key appears twice
file-not-foundThe imported config file doesn't exist
read-errorA config or .env file exists but can't be read
unsupported-filetyfigo1005The file isn't a config file, or (in tsc) its extension isn't one tyfigo reads
missing-variableA ${VAR} or ${VAR:?message} placeholder has no value
invalid-placeholdertyfigo1007A placeholder such as ${1PORT} or an unclosed ${PORT
unknown-keyTS2353An environment or local file sets a key the base file doesn't have
type-mismatchTS2322An environment or local file changes the kind of a value
browser-placeholderA browser build imports a file with a placeholder (Browser builds)
placeholder-typeA variable doesn't read as its placeholder's type (Placeholders)

In tsc, unknown-key and type-mismatch are ordinary TypeScript errors at the line in the config file. See Type checking for real output.

At run time

A config import that has problems throws when it is evaluated, and the import fails:

ConfigModuleError: Invalid config /srv/app/config/app.config.yaml
/srv/app/config/app.production.config.yaml:3:3 - 'server.hostname' is not in app.config.yaml; environment and local files can only override existing keys (unknown-key)
/srv/app/config/app.production.config.yaml:4:11 - Expected array at 'features' as in app.config.yaml, got number (type-mismatch)

The error has _tag: 'ConfigModuleError', the base file, and the problems array, each with file, line, column, message and code.

In builds

Bundler plugins fail the build with the same message. Server bundles leave missing-variable and placeholder-type to the start of the server, since the variables come from where it runs.

Schema errors

loadConfig and loadEnv throw (and the Effect versions fail with) a ConfigValidationError:

Invalid config /srv/app/config/app.config.yaml:
  /srv/app/config/app.config.yaml:2:9 - server.port: Too small: expected number to be >=1

Async schemas

loadConfig and loadEnv throw a TypeError naming loadConfigAsync and loadEnvAsync when the schema validates asynchronously.

On this page