mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-11-13 09:13:30 +01:00
fix(config): keep dict entries with "/" in keys during config migration
The automatic field migration recursed into every dict and addressed each
leaf by a "/"-joined path. Keys that themselves contain "/" - e.g. the config
paths used as keys of adapter.homeassistant.config_entity_ids - were split
into path elements. set_nested_value() then created a "devices" entry with
an empty string default and failed further down, so every version migration
replaced the mapping by {"devices": ""}.
Migrate a dict whose keys contain "/" as one value instead of per key.
Signed-off-by: SchaafAlexander <86607129+SchaafAlexander@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Bobby Noelte
co-authored by
Claude Opus 5.5
parent
93ccb8d592
commit
7767028a14
@@ -497,7 +497,15 @@ def _migrate_matching_fields(
|
||||
if full_path in migrated_source_paths:
|
||||
continue
|
||||
|
||||
if isinstance(value, dict):
|
||||
if isinstance(value, dict) and any("/" in str(k) for k in value):
|
||||
# Keys containing "/" (e.g. config paths used as mapping keys) can not be
|
||||
# addressed by a "/"-separated path - migrate the whole dict as one value.
|
||||
try:
|
||||
target_model.set_nested_value(full_path, value)
|
||||
count += 1
|
||||
except Exception:
|
||||
skipped_paths.append(full_path)
|
||||
elif isinstance(value, dict):
|
||||
count += _migrate_matching_fields(
|
||||
value, target_model, migrated_source_paths, skipped_paths, full_path
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user