What
docs/configuration.md says a config.yml typo never stops startup, and theme colors aren't on its fatal list. But UserConfig::load_theme passes color parse errors up with ?, so text: "300, 0, 0" aborts startup with a bare number too large to fit in target type that doesn't even name the field. Keybindings had the same bug (#441) and now warn and keep the default. Theme colors should too.
Where to look
All in src/core/user_config.rs:
load_theme: the to_theme_item! macro, and the cover_art_dither_color block above it
load_keybindings: the to_keys! macro, which is the pattern to copy
- the test
a_malformed_keybinding_keeps_the_default_and_still_loads
Possible solution
- In
to_theme_item!, match on parse_theme_item(&theme_item) the way to_keys! does, and log theme.<name> instead of keybindings.<name>.
- Do the same for
cover_art_dither_color, falling back to None. It only compiles with the cover-art feature.
- Leave
parse_theme_item alone: Settings and the Lua API rely on its Err.
- Add
a_malformed_theme_color_keeps_the_default_and_still_loads next to the keybinding test. UserTheme has no Default, so build it with serde_yaml::from_str("preset: Custom\ntext: '300, 0, 0'\nactive: '1, 2, 3'\n"), then assert load_theme returns Ok, text kept its default, and active is Color::Rgb(1, 2, 3).
- Each new
#[test] raises test_attribute_total in tools/gates.count by one. If the number is off, cargo test fails in src/gates.rs and prints the right one.
Done when
cargo test --no-default-features --features telemetry,tui a_malformed_theme_color says 1 passed.
cargo fmt --all -- --check, cargo clippy --no-default-features --features telemetry,tui -- -D warnings and cargo test --no-default-features --features telemetry,tui pass.
cargo clippy --no-default-features --features telemetry,tui,cover-art -- -D warnings passes too.
What
docs/configuration.mdsays a config.yml typo never stops startup, and theme colors aren't on its fatal list. ButUserConfig::load_themepasses color parse errors up with?, sotext: "300, 0, 0"aborts startup with a barenumber too large to fit in target typethat doesn't even name the field. Keybindings had the same bug (#441) and now warn and keep the default. Theme colors should too.Where to look
All in
src/core/user_config.rs:load_theme: theto_theme_item!macro, and thecover_art_dither_colorblock above itload_keybindings: theto_keys!macro, which is the pattern to copya_malformed_keybinding_keeps_the_default_and_still_loadsPossible solution
to_theme_item!, match onparse_theme_item(&theme_item)the wayto_keys!does, and logtheme.<name>instead ofkeybindings.<name>.cover_art_dither_color, falling back toNone. It only compiles with thecover-artfeature.parse_theme_itemalone: Settings and the Lua API rely on itsErr.a_malformed_theme_color_keeps_the_default_and_still_loadsnext to the keybinding test.UserThemehas noDefault, so build it withserde_yaml::from_str("preset: Custom\ntext: '300, 0, 0'\nactive: '1, 2, 3'\n"), then assertload_themereturnsOk,textkept its default, andactiveisColor::Rgb(1, 2, 3).#[test]raisestest_attribute_totalintools/gates.countby one. If the number is off,cargo testfails insrc/gates.rsand prints the right one.Done when
cargo test --no-default-features --features telemetry,tui a_malformed_theme_colorsays1 passed.cargo fmt --all -- --check,cargo clippy --no-default-features --features telemetry,tui -- -D warningsandcargo test --no-default-features --features telemetry,tuipass.cargo clippy --no-default-features --features telemetry,tui,cover-art -- -D warningspasses too.