Skip to content

Settings validator accepts whitespace-padded numbers the engine can't parse #883

Description

@genwave-radio

🐛 Problem

The settings validator accepts a number with surrounding whitespace, but the engine reads the same value as invalid. The saved setting then has no effect, and nothing tells the operator.

  • SettingValidator.IsDoubleInRange / IsDoubleAboveAndAtMost (src/GenWave.Host/Configuration/SettingValidator.cs) parse with NumberStyles.Float, which allows leading and trailing whitespace. So "3 " passes validation and is saved.
  • In the engine container, Liquidsoap's float_of_string("3 ") fails, so genwave.liq falls back to the default.

Result: the operator saves GW_XFADE_MIN = "3 ", gets a success, and the engine keeps running 2.0. Once F213 (gh-#879) ships, /api/status will also report a restartNeeded that no restart can clear.

The problem was found while reviewing T601, part of F213.

✅ Fix options

  1. Validator (preferred). Parse the engine-bound doubles with NumberStyles.AllowLeadingSign | AllowDecimalPoint | AllowExponent, so whitespace is rejected with a 400.
  2. Trim on save, so the stored value matches what the engine can parse.

Either way, add a spec: saving "3 " gives a 400, or it is stored as "3".

The affected keys are every number setting served by /internal/engine-config: GW_XFADE_MIN, GW_XFADE_MAX and GW_SAFE_GAP_SECONDS.

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 working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions