From 47b28e738c6030beb28dd999d447232f39d4b839 Mon Sep 17 00:00:00 2001 From: dborup Date: Sun, 26 Jul 2026 13:07:52 +0200 Subject: [PATCH] fix: sync_areas.py migrates existing areas with the stray regionScope key too The previous fix only stopped the script from writing the wrong field going forward. SE12 -- the one area actually created by today's buggy run -- falls through both remaining code paths: it's not in CROSSWALK (so the enrich step never touches it) and it already exists (so the "add new area" step skips it as already present). Without an explicit migration pass it would stay silently unlinked forever. Co-Authored-By: Claude Sonnet 5 --- ops/meshguide-sync/sync_areas.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ops/meshguide-sync/sync_areas.py b/ops/meshguide-sync/sync_areas.py index 073e8931..f307b049 100755 --- a/ops/meshguide-sync/sync_areas.py +++ b/ops/meshguide-sync/sync_areas.py @@ -118,6 +118,20 @@ def main(): confirmed_scopes = {v.get("scope") for v in cities.values() if v.get("scope")} confirmed_scopes |= set(regions.keys()) + # 0) one-time migration: an earlier version of this script wrote the + # singular "regionScope" key, which CoreScope's config schema never + # reads (it reads regionScopes, a list) -- silently invisible to the + # app. Areas created by that buggy run (not in CROSSWALK, so step 1 + # below never touches them, and already present, so step 2's "add new + # area" skips them too) would stay broken forever without this pass. + for area_key, entry in areas.items(): + legacy_scope = entry.pop("regionScope", None) + if legacy_scope: + scopes_list = entry.setdefault("regionScopes", []) + if legacy_scope not in scopes_list: + scopes_list.append(legacy_scope) + changed.append(f"migrated {area_key} ({entry.get('label')}) regionScope -> regionScopes") + # 1) enrich existing crosswalked areas for area_key, scope in CROSSWALK.items(): entry = areas.get(area_key)