Skip to content

Commit bde0456

Browse files
mbachorikCopilot
andauthored
Potential fix for pull request finding
Hardening - partially-corrupted registry degrades gracefully Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent e6627d6 commit bde0456

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/specify_cli/presets.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,16 @@ def list_by_priority(self) -> List[tuple]:
333333
Metadata is deep-copied to prevent accidental mutation.
334334
"""
335335
import copy
336-
packs = self.data["presets"]
336+
packs_raw = self.data.get("presets", {})
337+
packs = packs_raw if isinstance(packs_raw, dict) else {}
338+
items = []
339+
for pack_id, meta in packs.items():
340+
if not isinstance(meta, dict):
341+
# Skip malformed entries to keep registry iteration robust
342+
continue
343+
items.append((pack_id, copy.deepcopy(meta)))
337344
return sorted(
338-
[(pack_id, copy.deepcopy(meta)) for pack_id, meta in packs.items()],
345+
items,
339346
key=lambda item: (item[1].get("priority", 10), item[0]),
340347
)
341348

0 commit comments

Comments
 (0)