feat: validate configuration on startup, fail fast on bad config (#52)

A config value that is set but unparseable or invalid now aborts
startup with an error naming the offending key and value; defaults
apply only to omitted keys. Unknown top-level config keys and unknown
metrics subkeys abort startup naming each unknown key, so typos like
whitelist_hosts fail immediately instead of being silently ignored. A
config file that exists at a standard location but fails to parse is
now a fatal error instead of being skipped with a warning. state_dir
is verified creatable and writable with a probe file before the
listener binds. Port must be in 1-65535 (fractional values are
rejected, not truncated), upstream_connections_per_host must be at
least 1, allowlist_hosts entries must be bare hostnames, sentry_dsn
must be a valid URL when set, and metrics credentials must be set
together. The stale signing_key comment in config.example.yml (keyless
mode was never implemented) now states the actual requirement.
This commit is contained in:
2026-08-07 16:36:34 +00:00
parent f19da2c02c
commit f4c7dc4cd7
3 changed files with 329 additions and 37 deletions

View File

@@ -9,7 +9,7 @@ maintenance_mode: false
state_dir: ./data
# Image proxy settings
# HMAC signing key for URL signatures (leave empty to require allowlist for all requests)
# HMAC signing key for URL signatures (required, at least 32 characters)
# Generate with: openssl rand -base64 32
signing_key: "CHANGE_ME_generate_with_openssl_rand_base64_32"