Skip to content

An out-of-range theme color in config.yml stops spotatui from starting #547

Description

@LargeModGames

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions