Skip to content

fix: report a broken config file instead of silently using defaults - #125

Merged
ynqa merged 1 commit into
ynqa:mainfrom
VXNCXNX:fix/config-error-not-silent
Aug 20, 2026
Merged

fix: report a broken config file instead of silently using defaults#125
ynqa merged 1 commit into
ynqa:mainfrom
VXNCXNX:fix/config-error-not-silent

Conversation

@VXNCXNX

@VXNCXNX VXNCXNX commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Closes #117.

What's broken

A config file that fails to parse is discarded silently. No message, no warning, exit 0, and every customization is gone with no indication why.

A config that is valid TOML but incomplete does it too, which is the easier way to hit this by accident:

$ cat /tmp/partial.toml
no_hint = true

$ jnv --config /tmp/partial.toml
(defaults, no mention that the file was ignored)

The error was there all along, just thrown away:

TOML parse error at line 1, column 1
  |
1 | no_hint = true
  | ^
missing field `reactivity_control`

The cause

unwrap_or_else(|_e| ...) in main swallows the error and substitutes DEFAULT_CONFIG.

The fix

Propagate it. Now:

$ jnv --config /tmp/partial.toml
Error: TOML parse error at line 1, column 1
  |
1 | no_hint = true
  | ^
missing field `reactivity_control`

$ echo $?
1

Why failing is right here, rather than warning and continuing

ensure_file_exists already creates the file with the defaults when it is absent, for both the explicit --config path and the default location. So "no config" is handled before this point and never reaches it.

That means anything failing here is a file that exists and is broken, which is worth stopping for. A user who passes --config and gets defaults instead has silently lost their settings.

Tell me if you would rather warn and continue and I will change it.

Verification

A valid config still loads: running with default.toml gets past config loading to terminal setup as before.

cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test and cargo build all pass, matching the five steps in ci.yml.

No test added, because the repo currently has no test target at all and cargo test reports 0 tests. Adding a harness felt like a bigger change than the fix. Happy to add one if you want the infrastructure.

A parse failure was swallowed by unwrap_or_else, so a typo made every
customization vanish with no message and a zero exit. ensure_file_exists
already seeds a missing file with the defaults, so a failure here is real.

Closes ynqa#117

@ynqa ynqa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VXNCXNX Thanks, LGTM :)

@ynqa
ynqa merged commit f25b1f0 into ynqa:main Aug 20, 2026
6 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.

Invalid config file silently falls back to defaults with no error

2 participants