mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-04 22:35:08 +00:00
fix(plugins): normalize legacy boolean settings before schema validation (#588)
The news plugin's schema turned global.dynamic_duration from a boolean
into an {enabled, min_duration_seconds, ...} object. Installs that have
not saved the news settings since still hold `true`, so every start
logged "Plugin news config does not match its schema (loading anyway):
Field 'global.dynamic_duration': Expected type object, got bool" and
flagged news degraded.
The settings form already reads such a boolean as {"enabled": <bool>}
(render_nested_section in plugin_config.html) and the next save writes
the object. The loader did not. It now applies the same rule before
merging schema defaults and validating, so the defaults fill in the rest
of the object and the plugin receives it in the new shape.
The rule lives in schema_manager.legacy_bool_as_object /
normalize_legacy_booleans. It applies at any depth of nested objects
but not inside arrays, matching the form, and only to a real bool under
an object-typed property with an `enabled` child. Every other mismatch
still warns. A parity test renders the template macro against the helper
so the two cannot drift.
Nothing is written to config.json at load: the normalization is in
memory, and the next save of the plugin's settings persists the object.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1166,7 +1166,11 @@
|
||||
TypeError that takes down the whole config page. A legacy boolean was
|
||||
the on/off switch the object's `enabled` now holds, so carry it over --
|
||||
rendering {} would draw that checkbox unchecked and the next save would
|
||||
quietly turn the feature off. The save then writes the object. #}
|
||||
quietly turn the feature off. The save then writes the object.
|
||||
The plugin loader applies the same rule before validating
|
||||
(legacy_bool_as_object in src/plugin_system/schema_manager.py), and
|
||||
test/test_legacy_boolean_config.py renders this macro against it:
|
||||
change the two together. #}
|
||||
{% if value is mapping %}
|
||||
{% set nested_value = value %}
|
||||
{% elif value is boolean and 'enabled' in (prop.properties or {}) %}
|
||||
|
||||
Reference in New Issue
Block a user