Skip to content

Configuration: a file that does not parse stops the service - #316

Merged
vsilent merged 1 commit into
devfrom
fix/config-parse-error-is-fatal
Oct 30, 2026
Merged

vsilent merged 1 commit into
devfrom
fix/config-parse-error-is-fatal

Conversation

@vsilent

@vsilent vsilent commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Found by the user.role security audit. Companion of the OAuth fallback PR.

Problem. get_configuration (src/configuration.rs) started from Settings::default() and replaced it only if let Ok(loaded) = settings.try_deserialize(). A configuration that failed to parse, for example a typo or a wrong type in a production configuration.yaml, was silently ignored. The service then ran with auth at http://localhost:8080/me and the database at 127.0.0.1, with nothing in the log to explain why.

Change. New settings_from(config), which holds the same code as before: deserialize, then the environment overlays.

  • If a configuration is present but does not parse, the result is an error, and main stops with it.
  • If no configuration file is found at all, the defaults apply as before. CI and the test harness depend on this.
  • configuration.yaml.dist is never actually loaded: config::File::with_name does not recognise the .dist extension. That is why CI has always run on the defaults. This PR does not change that.

Tests

  • a_configuration_that_does_not_parse_is_an_error: failed against the old code (fell back to the default settings), passes now.
  • no_configuration_at_all_runs_on_the_defaults.
  • cargo test --lib passes (2305).
  • tests/bake_channels.rs passes both with a local configuration.yaml and without one (only the .dist file present, as in CI).

Production is not affected: the database is not read from the environment, so production could not run on the defaults, which means its configuration does parse.

🤖 Generated with Claude Code

get_configuration fell back to Settings::default() whenever the
configuration failed to deserialize, silently: auth at localhost, the
database at 127.0.0.1. A typo in a production configuration.yaml would
start a service on those defaults.

A configuration that is there but does not parse is now an error. With
no configuration file at all the defaults still apply: CI and the test
harness run that way (configuration.yaml.dist is not read - `with_name`
does not recognise the `.dist` extension).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vsilent
vsilent merged commit a251541 into dev Oct 30, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants